Categorygithub.com/handicraftsman/particlemsg_go
repositorypackage
0.4.0
Repository: https://github.com/handicraftsman/particlemsg_go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author

# README

ParticleMSG

A simple JSON messaging protocol for applications. Written with plugin managers in mind.

A sample session

C: {"Type": "_register", "Data": {"Name": "pluginName", "Key": "a sha256-hashed key"}}
S: {"Type": "_registered", "Data": {"Name": "pluginName"}}
OR
S: {"Type": "_alreadyRegistered", "Data": {"Name": "pluginName"}}
OR
S: {"Type": "_invalidKey", "Data": {"Key": "a sha256-hashed key"}}
OR
S: {"Type": "_blocked", "Data": {}} // means that server blocks everybody except for core
...
S: {"Type": "_ping", "Data": {}}
C: {"Type": "_pong", "Data": {}}
...
C: {"Type": "_message", "Data": {"To": "pluginName", "Message": {"Type": "aMessage", "Data": {"Some": "data"}}}}
S: {"Type": "_message", "Data": {"From": "pluginName", "Message": {"Type": "aMessage", "Data": {"Some": "data"}}}}
...
C: {"Type": "_quit", "Data": {}}
S: {"Type": "_quit", "Data": {"Reason": "Client Quit"}}

On _alreadyRegistered, _invalidKey and _blocked server receives messages of same types but with Who data field.

On register server generates {"Type": "_registered", "Data": {"Who": "pluginName"}} message.

On disconnect client generates {"Type": "_disconnect", "Data": {}} message.

On disconnect server generates {"Type": "_disconnect", "Data": {"Who": "pluginName"}} message.

Demo

Check test_client/main.go and test_server/main.go for demos.

$ cd /path/to/particlemsg_go/
$ bash ./genkey.sh pmsg
$ cd test_server
$ bash ./start.sh
Listening on 0.0.0.0:5050
core: &{_register map[Key:f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b Name:core]}
_server: &{_registered map[Name:core]}
core: &{_message map[Message:map[Data:map[baz:quux foo:bar] Type:foo] To:core]}
core: &{foo map[baz:quux foo:bar]}
_server: &{_message map[From:core Message:map[Type:foo Data:map[baz:quux foo:bar]]]}