public static void CreateSocketPair(out PairSocket socket1, out PairSocket socket2) { string address = string.Format("inproc://NetMQSocketPair#{0}", Interlocked.Increment(ref s_sequence)); socket1 = new PairSocket(); socket1.Bind(address); socket2 = new PairSocket(); socket2.Connect(address); }
/// <summary> /// Create and return an inproc pipe where socket1 is bound and socket2 is connected. /// </summary> /// <param name="socket1">the Bind socket</param> /// <param name="socket2">the Connect socket</param> public static void CreateSocketPair(out PairSocket socket1, out PairSocket socket2) { string address = $"inproc://NetMQSocketPair#{Interlocked.Increment(ref s_sequence)}"; socket1 = new PairSocket(); socket1.Bind(address); socket2 = new PairSocket(); socket2.Connect(address); }
protected WSSocket(NetMQContext context, IShimHandler<int> shimHandler ) { int id = Interlocked.Increment(ref s_id); m_context = context; m_messagesPipe = context.CreatePairSocket(); m_messagesPipe.Bind(string.Format("inproc://wsrouter-{0}", id)); m_messagesPipe.ReceiveReady += OnMessagePipeReceiveReady; m_actor = new Actor<int>(context, shimHandler, id); m_messagesPipe.WaitForSignal(); }
//this coroutine connects to ramulator and communicates how ramulator expects it to //in order to start the experiment session. follow it up with BeginNewTrial and //SetState calls public IEnumerator BeginNewSession(int sessionNumber) { //Connect to ramulator/////////////////////////////////////////////////////////////////// zmqSocket = new NetMQ.Sockets.PairSocket(); zmqSocket.Bind(address); //Debug.Log ("socket bound"); yield return(WaitForMessage("CONNECTED", "Ramulated not connected.")); //SendSessionEvent////////////////////////////////////////////////////////////////////// System.Collections.Generic.Dictionary <string, object> sessionData = new Dictionary <string, object>(); sessionData.Add("name", UnityEPL.GetExperimentName()); sessionData.Add("version", Application.version); sessionData.Add("subject", UnityEPL.GetParticipants()[0]); sessionData.Add("session_number", sessionNumber.ToString()); DataPoint sessionDataPoint = new DataPoint("SESSION", DataReporter.RealWorldTime(), sessionData); SendMessageToRamulator(sessionDataPoint.ToJSON()); yield return(null); //Begin Heartbeats/////////////////////////////////////////////////////////////////////// InvokeRepeating("SendHeartbeat", 0, 1); //SendReadyEvent//////////////////////////////////////////////////////////////////// DataPoint ready = new DataPoint("READY", DataReporter.RealWorldTime(), new Dictionary <string, object>()); SendMessageToRamulator(ready.ToJSON()); yield return(null); yield return(WaitForMessage("START", "Start signal not received")); InvokeRepeating("ReceiveHeartbeat", 0, 1); }