-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: To the Transport API. The "method" argument to Trans…
…port.RPC has been changed to an enum from a string. To update your code, all action strings like "Pickup" become api.Pickup. "AddPeer" becomes api.AddPeer and so on. I apologize for the breakage, but I think everyone will agree that this is worth it. Less strings in the binary and now you can autocomplete action names in your favorite IDE without typos or guessing. All known transports have been updated.
- Loading branch information
Showing
11 changed files
with
224 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package api | ||
|
||
// Action - API Call ID numbers | ||
type Action uint16 | ||
|
||
const ( | ||
Null Action = 0 | ||
ID Action = 1 | ||
Dropoff Action = 2 | ||
Pickup Action = 3 | ||
CID Action = 16 | ||
GetContact Action = 17 | ||
GetContacts Action = 18 | ||
AddContact Action = 19 | ||
DeleteContact Action = 20 | ||
GetChannel Action = 21 | ||
GetChannels Action = 22 | ||
AddChannel Action = 23 | ||
DeleteChannel Action = 24 | ||
GetProfile Action = 25 | ||
GetProfiles Action = 26 | ||
AddProfile Action = 27 | ||
DeleteProfile Action = 28 | ||
LoadProfile Action = 29 | ||
GetPeer Action = 30 | ||
GetPeers Action = 31 | ||
AddPeer Action = 32 | ||
DeletePeer Action = 33 | ||
Send Action = 34 | ||
SendChannel Action = 35 | ||
) | ||
|
||
/* | ||
// ActionToUint16 - returns the integer code for a string action name | ||
func ActionToUint16(action string) uint16 { | ||
switch action { | ||
case "ID": | ||
return ID | ||
case "Dropoff": | ||
return Dropoff | ||
case "Pickup": | ||
return Pickup | ||
case "CID": | ||
return CID | ||
case "GetContact": | ||
return GetContact | ||
case "GetContacts": | ||
return GetContacts | ||
case "AddContact": | ||
return AddContact | ||
case "DeleteContact": | ||
return DeleteContact | ||
case "GetChannel": | ||
return GetChannel | ||
case "GetChannels": | ||
return GetChannels | ||
case "AddChannel": | ||
return AddChannel | ||
case "DeleteChannel": | ||
return DeleteChannel | ||
case "GetProfile": | ||
return GetProfile | ||
case "GetProfiles": | ||
return GetProfiles | ||
case "AddProfile": | ||
return AddProfile | ||
case "DeleteProfile": | ||
return DeleteProfile | ||
case "LoadProfile": | ||
return LoadProfile | ||
case "GetPeer": | ||
return GetPeer | ||
case "GetPeers": | ||
return GetPeers | ||
case "AddPeer": | ||
return AddPeer | ||
case "DeletePeer": | ||
return DeletePeer | ||
case "Send": | ||
return Send | ||
case "SendChannel": | ||
return SendChannel | ||
} | ||
return Null | ||
} | ||
// ActionFromUint16 - returns the string name for an integer action code | ||
func ActionFromUint16(action uint16) string { | ||
switch action { | ||
case ID: | ||
return "ID" | ||
case Dropoff: | ||
return "Dropoff" | ||
case Pickup: | ||
return "Pickup" | ||
case CID: | ||
return "CID" | ||
case GetContact: | ||
return "GetContact" | ||
case GetContacts: | ||
return "GetContacts" | ||
case AddContact: | ||
return "AddContact" | ||
case DeleteContact: | ||
return "DeleteContact" | ||
case GetChannel: | ||
return "GetChannel" | ||
case GetChannels: | ||
return "GetChannels" | ||
case AddChannel: | ||
return "AddChannel" | ||
case DeleteChannel: | ||
return "DeleteChannel" | ||
case GetProfile: | ||
return "GetProfile" | ||
case GetProfiles: | ||
return "GetProfiles" | ||
case AddProfile: | ||
return "AddProfile" | ||
case DeleteProfile: | ||
return "DeleteProfile" | ||
case LoadProfile: | ||
return "LoadProfile" | ||
case GetPeer: | ||
return "GetPeer" | ||
case GetPeers: | ||
return "GetPeers" | ||
case AddPeer: | ||
return "AddPeer" | ||
case DeletePeer: | ||
return "DeletePeer" | ||
case Send: | ||
return "Send" | ||
case SendChannel: | ||
return "SendChannel" | ||
} | ||
return "" | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.