NeoLogin has released a publish-subscribe system based on WebSockets for the Neo blockchain. The PubSub system allows easy access to useful information such as smart contract events or other messages sent through the P2P network.
According to the team, the solution was designed to circumvent the need for developers to run full nodes in order to make off-chain applications aware of events happening on Neo. NeoLogin has noted that in addition to making the service open-source, it will also host and maintain public WebSocket servers for the community to use for free.
In addition to the written resources, examples of each socket channel can be found here. An example of a WebSocket connection to the tx channel can be found below, created as part of a Neo transaction finality visualizer.
In the example, the visualizer is using the PubSub service to monitor for new transactions on the Neo network. As each new transaction is broadcast, the visualizer receives the information published over the WebSocket channel and displays the transaction information in the above widget. The ability to retrieve information in this manner could be useful for hybrid applications that require a confirmation of activity on the Neo blockchain, such as a payment or smart contract invocation, to trigger an action.
Traditionally, developers would be required to run a full node to access this data which requires maintenance to ensure uptime and version compatibility. The ability to listen for events via the PubSub system alleviates this burden and allows programmers to instead focus on development.
NeoLogin’s free servers have been designed to scale automatically with demand, and can be used to retrieve events triggered during contract execution in addition to P2P messages for new transactions, blocks, and consensus messages.
NeoLogin also provided setup instructions for users that wish to deploy their own PubSub servers. The service can be added to any neo-cli instance using a NeoPubSub plugin, installation instructions can be found here.