Code Monkey home page Code Monkey logo

postmaster's Introduction

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"
)

func main(){
    server := postmaster.NewServer()

	//Assign auth callbacks
	server.GetAuthSecret = lookupUser
	server.GetAuthPermissions = getUserPremissions
	server.OnAuthenticated = userConnected
	server.OnDisconnect = clientDisconnected

	server.MessageToPublish = interceptMessage

	//Unauth rpc
	server.RegisterUnauthRPC(baseURL+"helloWorld",helloWorld)
	
	//Setup Authenticated RPC Functions
	server.RegisterRPC(baseURL+"helloWorldAuth",helloWorld)

    s := websocket.Server{Handler: postmaster.HandleWebsocket(server), Handshake: nil}
	http.Handle("/", s)

	if err := 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.
GetAuthSecret	func(authKey string)(string,error) // Required
//Get the permissions the session is granted when the authentication succeeds for the given key / extra information.
GetAuthPermissions func(authKey string,authExtra map[string]interface{})(Permissions,error) // Required
//Fired when client authentication was successful.
OnAuthenticated func(authKey string,authExtra map[string]interface{}, permission Permissions) // Optional

###Server Intercept

//Message interept
MessageToPublish PublishIntercept // Optional
//Fired when authenticated client disconnections
OnDisconnect func(authKey string,authExtra map[string]interface{}) //Optional

postmaster's People

Contributors

cvanderschuere avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.