private void ListenToOSC() { while (FListening) { try { OSCPacket packet = FOSCReceiver.Receive(); if (packet != null) { lock (FMessageQueue) if (packet.IsBundle()) { ArrayList messages = packet.Values; for (int i = 0; i < messages.Count; i++) { FMessageQueue.Add((OSCMessage)messages[i]); } } else { FMessageQueue.Add((OSCMessage)packet); } } } catch (Exception e) { FLogger.Log(LogType.Debug, "UDP: " + e.Message); } } }
void UpdateOSC() { while (true) { OSCPacket msg = oscin.Receive(); if (msg != null) { if (msg.IsBundle()) { //Debug.Log ("msg is bundle"); OSCBundle b = (OSCBundle)msg; foreach (OSCPacket subm in b.Values) { parseMessage(subm); } } else { // Debug.Log ("msg is singular"); parseMessage(msg); } } //Debug.Log("while loop works"); // Thread.Sleep( 5 ); } }
private void listen() { while (connected) { try { OSCPacket packet = receiver.Receive(); if (packet != null) { lock (processQueue){ //Debug.Log( "adding packets " + processQueue.Count ); if (packet.IsBundle()) { ArrayList messages = packet.Values; for (int i = 0; i < messages.Count; i++) { processQueue.Add((OSCMessage)messages[i]); } } else { processQueue.Add((OSCMessage)packet); } } } else { Console.WriteLine("null packet"); } } catch (Exception e) { Debug.Log(e.Message); Console.WriteLine(e.Message); } } }
private void listen() { while (connected) { try { OSCPacket packet = receiver.Receive(); if (packet != null) { if (packet.IsBundle()) { ArrayList messages = packet.Values; for (int i = 0; i < messages.Count; i++) { processMessage((OSCMessage)messages[i]); } } else { processMessage((OSCMessage)packet); } } else { Console.WriteLine("null packet"); } } catch (Exception e) { Console.WriteLine(e.Message); } } }
private void ListenToOSC() { while (FListening) { try { OSCPacket packet = FOSCReceiver.Receive(); if (packet != null) { if (packet.IsBundle()) { ArrayList messages = packet.Values; for (int i = 0; i < messages.Count; i++) { ProcessOSCMessage((OSCMessage)messages[i]); } } else { ProcessOSCMessage((OSCMessage)packet); } } else { DebugLog.Items.Add("UDP: null packet received!"); } } catch (Exception e) { DebugLog.Items.Add("UDP: " + e.Message); } } }
private void listen() { while (connected) { try { OSCPacket packet = receiver.Receive(); if (packet != null) { if (packet.IsBundle()) { List <object> messages = packet.Values; for (int i = 0, ic = messages.Count; i < ic; i++) { processMessage((OSCMessage)messages[i]); } } else { processMessage((OSCMessage)packet); } } } catch (Exception e) { // HACK : Exception notification changed to debug output by frog (@rktut) System.Diagnostics.Debug.WriteLine(e.ToString()); } } }
// Update is called once per frame void PacketReceived(OSCServer sender, OSCPacket Packet) { if (Packet.IsBundle()) { for (int i = 0; i < Packet.Data.Count; ++i) { try { HandleMessage((OSCMessage)Packet.Data[i]); } catch (System.Exception e) { Debug.LogError(e.Message); Debug.LogError(e.StackTrace); } } } else { try { HandleMessage((OSCMessage)Packet); } catch (System.Exception e) { Debug.LogError(e.Message); Debug.LogError(e.StackTrace); } } }
// Update is called once per frame void Update() { if (!HasInit) { return; } while (queue.Count > 0) { OSCPacket packet = queue.Dequeue() as OSCPacket; if (packet.IsBundle()) { // OSCBundleの場合 OSCBundle bundle = packet as OSCBundle; foreach (OSCMessage msg in bundle.Data) { if (OSCMessageReceivedEvent != null) { OSCMessageReceivedEvent(msg); } } } else { OSCMessage msg = packet as OSCMessage; if (OSCMessageReceivedEvent != null) { OSCMessageReceivedEvent(msg); } } } }
void Update() { if (queue == null) { return; } while (0 < queue.Count) { OSCPacket packet = queue.Dequeue() as OSCPacket; if (packet.IsBundle()) { // if OSCBundl OSCBundle bundle = packet as OSCBundle; foreach (OSCMessage msg in bundle.Data) { } } else { OSCMessage msg = packet as OSCMessage; if ("/unity_osc" == msg.Address) { if (onMsg != null) { onMsg(msg); } } } } }
public void UpdateListen() { if (!_isInit) { return; } while (_packets.Count > 0) { OSCPacket packet = _packets.Dequeue(); if (packet == null) { return; } if (packet.IsBundle()) { OSCBundle bundle = packet as OSCBundle; OnListenOSCBundle.SafeInvoke(bundle); } else { OSCMessage message = packet as OSCMessage; OnListenOSCMessage.SafeInvoke(message); } } }
void OnPacketReceived(OSCServer server, OSCPacket packet) { if (simular) { if (packet.Address == "/add") { create_tag(packet as OSCMessage); } else if (packet.Address == "/remove") { int index = get_tag_by_id((string)packet.Data [0]); if (index != -1) { tags.RemoveAt(index); } } else if (packet.Address == "/update") { int index = get_tag_by_id((string)packet.Data [0]); if (index != -1) { (tags [index] as MMTag).x = (float)packet.Data [1]; (tags [index] as MMTag).y = (float)packet.Data [2]; (tags [index] as MMTag).angle = ((float)packet.Data [3]) * Mathf.Rad2Deg; } } } else { if (packet.IsBundle()) { foreach (OSCMessage o in packet.Data) { if (o.Address == "/add") { create_tag(o); } else if (o.Address == "/remove") { int index = get_tag_by_id((string)o.Data [0]); if (index != -1) { tags.RemoveAt(index); } } else if (o.Address == "/update") { int index = get_tag_by_id((string)o.Data [0]); if (index != -1) { (tags [index] as MMTag).x = (float)o.Data [1]; (tags [index] as MMTag).y = (float)o.Data [2]; (tags [index] as MMTag).angle = ((float)o.Data [3]) * Mathf.Rad2Deg; } } } } } }
#pragma warning restore public void Evaluate(int SpreadMax) { if (FInput.IsAnyInvalid() || FExtendedMode.IsAnyInvalid()) { SpreadMax = 0; } else { SpreadMax = FInput.SliceCount; } if (SpreadMax == 0) { if (FOutput.SliceCount != 0) { FOutput.SliceCount = 0; FOutput.Flush(); } return; } if (!FInput.IsChanged && !FExtendedMode.IsChanged) { return; } FOutput.SliceCount = SpreadMax; for (int i = 0; i < SpreadMax; i++) { FOutput[i].SliceCount = 0; MemoryStream ms = new MemoryComStream(); FInput[i].Position = 0; FInput[i].CopyTo(ms); byte[] bytes = ms.ToArray(); int start = 0; OSCPacket packet = OSCPacket.Unpack(bytes, ref start, (int)FInput[i].Length, FExtendedMode[0]); if (packet.IsBundle()) { var packets = ((OSCBundle)packet).Values; foreach (OSCPacket innerPacket in packets) { MemoryStream memoryStream = new MemoryStream(innerPacket.BinaryData); FOutput[i].Add(memoryStream); } } else { MemoryStream memoryStream = new MemoryStream(packet.BinaryData); FOutput[i].Add(memoryStream); } } FOutput.Flush(); }
protected void InvokePacket(OSCPacket packet) { if (packet.IsBundle()) { InvokeBundle(packet as OSCBundle); } else { InvokeMessage(packet as OSCMessage); } }
public static void Packet(OSCPacket packet) { if (packet.IsBundle()) { DrawBundle(packet as OSCBundle); } else { DrawMessage(packet as OSCMessage); } }
void Update() { while (0 < queue.Count) { OSCPacket packet = queue.Dequeue() as OSCPacket; if (packet.IsBundle()) { // OSCBundleの場合 OSCBundle bundle = packet as OSCBundle; foreach (OSCMessage msg in bundle.Data) { // メッセージの中身にあわせた処理 } } else { // OSCMessageの場合はそのまま変換 OSCMessage msg = packet as OSCMessage; // メッセージの中身にあわせた処理 //InfoWindow.Log("osc: " + msg.Address); if (msg.Address == "/data") { if (msg.Data.Count >= 1) { dataDistributer.SetData(msg.Data[0].ToString()); logWriter.WriteLine(msg.Data[0].ToString()); } } else if (msg.Address == "/reset") { dataDistributer.Reset(); } else if (msg.Address == "/sim") { if (msg.Data.Count >= 1) { dataDistributer.SetSimulationData(msg.Data[0].ToString()); } } else if (msg.Address == "/simclear") { dataDistributer.ClearSimulationData(); } // 展示用 else if (msg.Address == "/start") { Debug.Log("receive /start"); dummySender.RestartDemoMode(); } } } }
public static string GeneratePacket(OSCPacket packet) { if (packet.IsBundle()) { return(GenerateBundle(packet as OSCBundle)); } else { return(GenerateMessage(packet as OSCMessage)); } }
public void DrawLayout(OSCPacket packet) { if (packet.IsBundle()) { DrawBundle((OSCBundle)packet); } else { DrawMessage((OSCMessage)packet); } }
public static void EditablePacket(OSCPacket packet) { if (packet.IsBundle()) { DrawEditableBundle(packet as OSCBundle); } else { DrawEditableMessage(packet as OSCMessage); } }
void HandlePacket(OSCPacket packet) { if (packet.IsBundle()) { foreach (OSCMessage mes in packet.Data) { HandleMessage(mes); } } else { HandleMessage(packet); } }
void PackedReceived(OSCServer sender, OSCPacket packet) { if (packet.IsBundle()) { foreach (OSCMessage m in packet.Data) { HandleMessage(m); } } else { HandleMessage(packet as OSCMessage); } }
void packetReceived(OSCPacket p) { if (p.IsBundle()) { foreach (OSCMessage m in p.Data) { processMessage(m); } } else { processMessage((OSCMessage)p); } // Debug.Log("Packet processed"); }
private void ProcessPacket(OSCPacket packet) { if (packet.IsBundle()) { OSCBundle bundle = packet as OSCBundle; foreach (object o in bundle.Values) { this.ProcessPacket(o as OSCPacket); } } else { this.ProcessMessage(packet as OSCMessage); } }
private static string PacketToString(OSCPacket packet) { if (!packet.IsBundle()) { return(string.Format("<color=orange>Message:</color> {0}", packet.Address)); } var bundle = packet as OSCBundle; if (bundle != null) { return(string.Format("<color=yellow>Bundle:</color> (Packets: {0})", bundle.Packets.Count)); } return(string.Empty); }
#pragma warning restore public void Evaluate(int SpreadMax) { if (!FInput.IsChanged) { return; } if ((FInput.SliceCount == 0) || (FInput[0] == null) || (FInput[0].Length == 0)) { return; } SpreadMax = FInput.SliceCount; FOutput.SliceCount = SpreadMax; for (int i = 0; i < SpreadMax; i++) { FOutput[i].SliceCount = 0; MemoryStream ms = new MemoryStream(); FInput[i].Position = 0; FInput[i].CopyTo(ms); byte[] bytes = ms.ToArray(); int start = 0; OSCPacket packet = OSCPacket.Unpack(bytes, ref start, (int)FInput[i].Length); if (packet.IsBundle()) { var packets = ((OSCBundle)packet).Values; foreach (OSCPacket innerPacket in packets) { MemoryStream memoryStream = new MemoryStream(innerPacket.BinaryData); FOutput[i].Add(memoryStream); } } else { MemoryStream memoryStream = new MemoryStream(packet.BinaryData); FOutput[i].Add(memoryStream); } } FOutput.Flush(); }
void didRecievedEvent(OSCServer sender, OSCPacket packet) { lock (_queue) { if (packet.IsBundle()) { var bundle = packet as OSCBundle; foreach (object obj in bundle.Data) { OSCMessage msg = obj as OSCMessage; _queue.Enqueue(msg); } } else { _queue.Enqueue(packet as OSCMessage); } } }
void Update() { while (0 < queue.Count) { OSCPacket packet = queue.Dequeue() as OSCPacket; if (packet.IsBundle()) { OSCBundle bundle = packet as OSCBundle; foreach (OSCMessage msg in bundle.Data) { Receive(msg); } } else { OSCMessage msg = packet as OSCMessage; Receive(msg); } } }
private void processOSCPacket(OSCPacket packet) { if (packet != null) { lastPacket = packet; if (packet.IsBundle()) { ArrayList messages = packet.Values; for (int i = 0; i < messages.Count; i++) { processMessage((OSCMessage)messages[i]); } } else { processMessage((OSCMessage)packet); } } }
void Update() { //Debug.Log("Updating"); if (queue == null) { //Debug.Log("nada"); return; } while (0 < queue.Count) { //Debug.Log("HAS STUFF"); OSCPacket packet = queue.Dequeue() as OSCPacket; if (packet.IsBundle()) { // if OSCBundl OSCBundle bundle = packet as OSCBundle; foreach (OSCMessage msg in bundle.Data) { } } else { OSCMessage msg = packet as OSCMessage; //Debug.Log(msg.Address); if ("/unity_osc" == msg.Address) { //print (msg.Data[1].ToString()); var thing = msg.Data[1].ToString(); var pos = new Vector3((float)msg.Data[2], (float)msg.Data[3], (float)msg.Data[4]); //rb.MovePosition(pos); var dur = (float)packet.Data[5]; AppendItem(thing, pos, dur); } } } }
public override string ToString() { if (_description == null && _packet != null) { var packetDescription = string.Empty; if (!_packet.IsBundle()) { packetDescription = string.Format("<color=orange>Message:</color> {0}", _packet.Address); } var bundle = _packet as OSCBundle; if (bundle != null) { packetDescription = string.Format("<color=yellow>Bundle:</color> (Packets: {0})", bundle.Packets.Count); } _description = packetDescription + "\n" + _info; } return(_description); }
void ListenToOSCMessage() { while (0 < queue.Count) { OSCPacket packet = queue.Dequeue() as OSCPacket; if (packet.IsBundle()) { OSCBundle bundle = packet as OSCBundle; foreach (OSCMessage msg in bundle.Data) { onListenToOSCMessage(msg); } } else { OSCMessage msg = packet as OSCMessage; onListenToOSCMessage(msg); } } }