public void StopServer() { if (!ServerRunning) { return; } poller?.Stop(); poller?.Dispose(); lock (responseSocketLock) { if (responseSocket != null) { try { responseSocket.Disconnect(responseSocketConnectionString); } finally { responseSocket.Close(); responseSocket = null; } } } }
public override void WillTerminate(NSNotification notification) { _socketServer?.Disconnect(Ipc.RepoZIpcEndpoint.Address); _socketServer?.Dispose(); // Insert code here to tear down your application NSEvent.RemoveMonitor(_eventMonitor); }
protected virtual void Dispose(bool disposing) { if (disposing) { _socketServer?.Disconnect(EndpointProvider.Address); _socketServer?.Dispose(); _socketServer = null; } }
protected override void Run() { ForceDotNet.Force(); // this line is needed to prevent unity freeze after one use, not sure why yet using (server = new ResponseSocket()) // check if its response or request ? { server.Bind("tcp://*:1234"); //SEND using (client = new RequestSocket()) { client.Connect("tcp://localhost:2222"); // RECIEVE // for (int i = 0; i < 2 && Running; i++) while (Running) { // TO BE ABLE TO SEND USING SERVER SOCKET: string DummyServerReceive = server.ReceiveFrameString(); //Debug.Log("MY DUMMY SERVER REC: " + DummyServerReceive); //SENDING TO SERVER : //SEND A VARIABLE BOOLEAN HERE server.SendFrame(Mode + "," + Yindex + "," + Xindex + "," + Resign + "," + Pass + "," + HumanColor); //Pass = "******"; //Resign = "-1"; //Debug.Log("SERVER IS DONE "); // DUMMY SEND OF CLIENT TO RECEIVE client.SendFrame("HELLOOOOOOO"); while (Running) { message = client.ReceiveFrameString(); // this returns true if it's successful //Debug.Log("MESSAGE IS :" + this.message); break; } } client.Disconnect("tcp://localhost:2222"); client.Close(); client.Dispose(); } server.Disconnect("tcp://*:1234"); server.Close(); server.Dispose(); } NetMQConfig.Cleanup(); }
protected override void OnExit(ExitEventArgs e) { _socketServer?.Disconnect(Ipc.RepoZIpcEndpoint.Address); _socketServer?.Dispose(); _hotkey.Unregister(); _explorerUpdateTimer.Change(Timeout.Infinite, Timeout.Infinite); var explorerHandler = TinyIoCContainer.Current.Resolve <WindowsExplorerHandler>(); explorerHandler.CleanTitles(); _notifyIcon.Dispose(); base.OnExit(e); }
private void dataServer() { AsyncIO.ForceDotNet.Force(); using (var dataSender = new ResponseSocket()) { dataSender.Bind("tcp://" + VPETSettings.Instance.serverIP + ":5565"); Debug.Log("Enter while.. "); while (isRunning) { string message = ""; dataSender.TryReceiveFrameString(out message); //print ("Got request message: " + message); // re-run scene iteration if true if (doGatherOnRequest) { gatherSceneData(); } switch (message) { case "header": print("Send Header.. "); dataSender.SendFrame(headerByteData); print(string.Format(".. Nodes ({0} bytes) sent ", headerByteData.Length)); break; case "nodes": print("Send Nodes.. "); dataSender.SendFrame(nodesByteData); print(string.Format(".. Nodes ({0} bytes) sent ", nodesByteData.Length)); break; case "objects": print("Send Objects.. "); dataSender.SendFrame(objectsByteData); print(string.Format(".. Objects ({0} bytes) sent ", objectsByteData.Length)); break; case "characters": print("Send Characters.. "); dataSender.SendFrame(charactersByteData); print(string.Format(".. Characters ({0} bytes) sent ", charactersByteData.Length)); break; case "textures": print("Send Textures.. "); dataSender.SendFrame(texturesByteData); print(string.Format(".. Textures ({0} bytes) sent ", texturesByteData.Length)); break; #if TRUNK case "materials": print("Send Materials.. "); dataSender.SendFrame(materialsByteData); print(string.Format(".. Materials ({0} bytes) sent ", materialsByteData.Length)); break; #endif default: break; } } // TODO: check first if closed try { dataSender.Disconnect("tcp://" + VPETSettings.Instance.serverIP + ":5565"); dataSender.Dispose(); dataSender.Close(); } finally { NetMQConfig.Cleanup(false); } } }