Documentation ¶
Overview ¶
Package msg provides marshalling and unmarshalling functions for messages over websockets. Messages are formatted as such:
{OP_CODE} {PAYLOAD}
With a single space delimiting the op code from the payload. Where the payload is a json value, i.e., a json string/array/number/object, but may be omitted if no payload is necessary.
Messages from the server to the client: S_UserList - Sent on first connection with Angelina
["string"] // Array of user identifiers '{REGION}_{UID}'
S_NewUser - When a new user logs in through Rhine
"string" // User identifier '{REGION}_{UID}'
S_Attached
"string" // User identifier '{REGION}_{UID}'
S_Detached - When the connected user is disconnected
No payload.
S_Hooked - On successful hook request.
{ "id": "string", // Required for unhooking "type": "string", // 'gamestate' or 'packet' "target": "string", "event": "boolean" // Optional, false if not sent }
S_Unhooked - On successful unhook request.
"string"
S_HookEvt - Sent when a hook generates an event.
{ "type": "string", // 'gamestate' or 'packet' "target": "string", // data's JSON type may vary depending on the hook target. // Omitted if the hook is an event type "data": "data object" }
S_Get - Sent after the client sends a C_Get request if the get is successful.
{ "path": "string", "data": "data object" }
S_Error - Sent when an error was generated while handling of a request.
{ "request": "string", // The request message that generated the error "error": "string" }
Messages from the client to the server: C_Attach - C_Attach is sent from the websocket client to request for the server to attach them to the specified game user. A websocket client can only be attached to one user at a time and it is required for hooking and getting information from their game state.
"string"
C_Detach - unhooks all registered hooks and allows the websocket client to attach to another user.
No payload
C_Get - requests a piece of information from the attached user's game state.
"string"
C_Hook - requests a hook to be made on either a certain packet being received or if there's a change to the gamestate in a certain path. The event value specifies if the websocket client only needs to be notified of the change or packet and not sent the data itself.
{ "type": "string", // 'gamestate' or 'packet' "target": "string", "event": "boolean" // Optional, defaults to false }
C_Unhook - stop listening on an event.
"string" // Hook ID
Index ¶
- func ServerAttached(user string) ([]byte, error)
- func ServerDetach() ([]byte, error)
- func ServerError(request []byte, err string) ([]byte, error)
- func ServerGet(path string, data interface{}) ([]byte, error)
- func ServerHookEvt(kind, target string, data interface{}) ([]byte, error)
- func ServerHooked(id uint64, kind, target string, event bool) ([]byte, error)
- func ServerNewUser(user string) ([]byte, error)
- func ServerUnhooked(id uint64) ([]byte, error)
- func ServerUserList(users []string) ([]byte, error)
- func UnmarshalClientAttach(payload []byte) (string, error)
- func UnmarshalClientGet(payload []byte) (string, error)
- func UnmarshalClientUnhook(payload []byte) (string, error)
- type Hook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServerAttached ¶
ServerAttached creates a message notifying the client that they've successfully attached to a user.
func ServerDetach ¶
ServerDetach creates a message notifying the client that the user they were attached to has disconnected.
func ServerError ¶
ServerError creates a message to notify the client that an error has occurred during the handling of a request.
func ServerHookEvt ¶
ServerHookEvt notifies the client when a hook generates an event.
func ServerHooked ¶
ServerHooked creates a message to notify the client that they have successfully registered a hook for an event.
func ServerNewUser ¶
ServerNewUser creates a message notifying the client that a new user has connected through Rhine and is available to attach to.
func ServerUnhooked ¶
ServerUnhooked creates a message to notify that they have successfully unhooked for an event.
func ServerUserList ¶
ServerUserList creates a message informing the client of the already attached users that are available to attach to.
func UnmarshalClientAttach ¶
func UnmarshalClientGet ¶
func UnmarshalClientUnhook ¶
UnmarshalClientUnhook unmarshals the payload of the C_Unhook message.