private void Server_PacketReceived(object sender, OscPacketReceivedEventArgs e) { if (e.Packet.Data.Count == 1) { debug("Packet Received: " + e.Packet.Address + " = " + e.Packet.Data[0]); } else { debug("Packet Received: " + e.Packet.Address); foreach (object o in e.Packet.Data) { debug(" " + o.ToString()); } } switch(e.Packet.Address) { case "/1/fader1": joystickState.AxisX = (float) e.Packet.Data[0]; break; case "/1/fader2": joystickState.AxisY = (float) e.Packet.Data[0]; break; } debug("Packet parsed"); }
/// <summary> /// Server Response from QLab /// </summary> void server_PacketReceived(object sender, OscPacketReceivedEventArgs e) { //If the designer has created an event handler, return base information if (OSCResponse != null) { bool doContinue = this.OSCResponse.Invoke(e.Packet.Address, e.Packet.Data[0].ToString()); if (!doContinue) return; } //Set the static ReplyAddressHold to be found by the caller __ReplyAddressHolder = e.Packet.Address; if (e.Packet.Address.StartsWith("/reply")) //General Workspace Request { Dictionary<string, object> response = JsonConvert.DeserializeObject<Dictionary<string, object>>(e.Packet.Data[0].ToString()); //Set the static ReplyValueHolder to found by the caller and end the SpinWait lock __ReturnAddressHolder = response["address"].ToString(); __ReturnValueHolder = response["data"]; } if (e.Packet.Address.StartsWith("/update")) //General Workspace Request { //Update command has been called. Determine the appropriate response //And if the designer has created an event handler, invoke the handler if (e.Packet.Address.Contains("/cue_id/")) { if (CueUpdated != null) { string workspaceID = e.Packet.Address.Replace("/update/workspace/", ""); workspaceID = workspaceID.Substring(0, workspaceID.IndexOf("/")); string cueID = e.Packet.Address.Replace("/update/workspace/" + workspaceID + "/cue_id/", ""); CueUpdated.Invoke(workspaceID, cueID); } } else { if (WorkspaceUpdated != null) { string workspaceID = e.Packet.Address.Replace("/update/workspace/", ""); WorkspaceUpdated.Invoke(workspaceID); } } } }