public void InitializeSubscriptionSocket(string topic) { if (!subscriptionSocketForTopic.ContainsKey(topic)) { subscriptionSocketForTopic.Add(topic, new SubscriberSocket(IPHeader + subport)); subscriptionSocketForTopic [topic].Subscribe(topic); //André: Is this necessary?? // subscriptionSocketForTopic[topic].Options.SendHighWatermark = PupilSettings.numberOfMessages;// 6; subscriptionSocketForTopic[topic].ReceiveReady += (s, a) => { int i = 0; NetMQMessage m = new NetMQMessage(); while (a.Socket.TryReceiveMultipartMessage(ref m)) { // We read all the messages from the socket, but disregard the ones after a certain point // if ( i > PupilSettings.numberOfMessages ) // 6) // continue; mStream = new MemoryStream(m[1].ToByteArray()); string msgType = m[0].ConvertToString(); if (PupilTools.Settings.debug.printMessageType) { Debug.Log(msgType); } if (PupilTools.Settings.debug.printMessage) { Debug.Log(MessagePackSerializer.ToJson(m[1].ToByteArray())); } switch (msgType) { case "notify.calibration.successful": PupilTools.Settings.calibration.currentStatus = Calibration.Status.Succeeded; PupilTools.CalibrationFinished(); Debug.Log(msgType); break; case "notify.calibration.failed": PupilTools.Settings.calibration.currentStatus = Calibration.Status.NotSet; PupilTools.CalibrationFailed(); Debug.Log(msgType); break; case "gaze": case "pupil.0": case "pupil.1": var dictionary = MessagePackSerializer.Deserialize <Dictionary <string, object> > (mStream); if (PupilTools.ConfidenceForDictionary(dictionary) > 0.6f) { if (msgType == "gaze") { PupilTools.gazeDictionary = dictionary; } else if (msgType == "pupil.0") { PupilTools.pupil0Dictionary = dictionary; } else if (msgType == "pupil.1") { PupilTools.pupil1Dictionary = dictionary; } } break; default: Debug.Log(msgType); // foreach (var item in MessagePackSerializer.Deserialize<Dictionary<string,object>> (mStream)) // { // Debug.Log(item.Key); // Debug.Log(item.Value.ToString()); // } break; } i++; } }; } }