Skip to content

Repository files navigation

Postmaster

General purpose wamp messaging server

  • Pass messages following WAMP protocol
  • Support for server side message intercept
  • Support for server events OnAuthenticated and OnDisconnect per connection
  • Scalable (Initial work to make multi-instance aware)

##Getting Started

Here is an example server that can be made with Postmaster.

Features of this example:

  • Authentication
  • Callbacks
  • Unauthenticated RPC
  • Authenticated RPC
import (
"postmaster""code.google.com/p/go.net/websocket"
)
funcmain(){
server:=postmaster.NewServer()
//Assign auth callbacksserver.GetAuthSecret=lookupUserserver.GetAuthPermissions=getUserPremissionsserver.OnAuthenticated=userConnectedserver.OnDisconnect=clientDisconnectedserver.MessageToPublish=interceptMessage//Unauth rpcserver.RegisterUnauthRPC(baseURL+"helloWorld",helloWorld)
//Setup Authenticated RPC Functionsserver.RegisterRPC(baseURL+"helloWorldAuth",helloWorld)
s:= websocket.Server{Handler: postmaster.HandleWebsocket(server), Handshake: nil}
http.Handle("/", s)
iferr:=http.ListenAndServe(":8080", nil); err!=nil {
log.Fatal("ListenAndServe:", err)
}
}
/* TODO: Define all of the callback functions*/

##Callbacks

###Authentication

//Get the authentication secret for an authentication key, i.e. the user password for the user name. Return "" when the authentication key does not exist.GetAuthSecretfunc(authKeystring)(string,error) // Required
//Get the permissions the session is granted when the authentication succeeds for the given key / extra information.GetAuthPermissionsfunc(authKeystring,authExtramap[string]interface{})(Permissions,error) // Required
//Fired when client authentication was successful.OnAuthenticatedfunc(authKeystring,authExtramap[string]interface{}, permissionPermissions) // Optional

###Server Intercept

//Message intereptMessageToPublishPublishIntercept// Optional
//Fired when authenticated client disconnectionsOnDisconnectfunc(authKeystring,authExtramap[string]interface{}) //Optional

About

General purpose web socket messaging server (Golang)

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages