internal byte[] KeepRequest(byte[] req) { if (mqClient == null) { mqClient = new ZMQClient(); mqClient.Address = address; } return(mqClient.Send(req)); }
void Start() { zmqClient = GetComponent <ZMQClient>(); ExtractHardware(); zmqClient.unityPacket.hardware.Clear(); zmqClient.unityPacket.hardware.AddRange(hardware); Debug.Log("Hardware length: " + zmqClient.unityPacket.hardware.Count); }
public static void Main(string[] args) { // get the subscription handler ready (tracks websocket clients and their subscriptions) _subscriptionHandler = new SubscriptionHandler(); // get the dataHandler ready (handles incoming blocks and transactions, compares to client subscriptions using the subscription handler) _dataHandler = new DataHandler(_subscriptionHandler); // start with a ZMQ connection for blocks var blockConsumer = new BlockConsumer(_dataHandler.HandleBlock); var zmqBlockClient = new ZMQClient(Config.GetConfigString("ZMQBlockHostname"), Config.GetConfigInt("ZMQBlockPort"), "rawblock", (frameHeader, data, frameCounter) => blockConsumer.EnqueueTask(data, frameCounter)); // start a ZMQ subscription for transactions var transactionConsumer = new TransactionConsumer(_dataHandler.HandleTransaction); var zmqTxClient = new ZMQClient(Config.GetConfigString("ZMQTxHostname"), Config.GetConfigInt("ZMQTxPort"), "rawtx", (frameHeader, data, frameCounter) => transactionConsumer.EnqueueTask(data, frameCounter)); // initialize websocket server // TODO: we need an x509 certificate including key to use secure (wss) - add to application config options _server = new WebsocketServer(IPAddress.Parse(Config.GetConfigString("WebsocketBindIP")), Config.GetConfigInt("WebsocketBindPort"), false, false) // restart websocket listener automatically { RestartAfterListenError = true }; // start the websocket server, and add callbacks to track active sockets _server.Start(socket => { socket.OnOpen = () => { // track the connection _subscriptionHandler.AddSocket(socket); }; socket.OnClose = () => { // stop tracking this connection _subscriptionHandler.RemoveSocket(socket); }; socket.OnMessage = message => { // process incoming message MessageHandler.HandleMessage(socket, message, _subscriptionHandler); }; socket.OnError = exception => { // TODO: handle websocket exceptions }; }); }
internal void KeepClose() { mqClient.Address = address; mqClient.Close(); mqClient = null; }
internal byte[] Request(byte[] req) { ZMQClient client = new ZMQClient(); return(client.Send(address, req)); }
private void Start() { zmqClient = GetComponent <ZMQClient>(); }