protected void InGameControls() { GUI.color = _transmitter.IsStarted ? Color.green : Color.red; if (GUILayout.Button(_transmitter.IsStarted ? "Connected" : "Disconnected")) { if (_transmitter.IsStarted) { _transmitter.Close(); } else { _transmitter.Connect(); } } GUI.color = Color.yellow; GUI.enabled = _transmitter.IsStarted; if (GUILayout.Button("Reconnect")) { if (_transmitter.IsStarted) { _transmitter.Close(); } _transmitter.Connect(); } GUI.enabled = true; }
private void InitNetwork() { if (!FAutoIP.Equals(FTargetIP) || FAutoPort != FTargetPort) { FTargetIP = FAutoIP; FTargetPort = FAutoPort; if (FTargetIP != null) { try { if (FOSCTransmitter != null) { FOSCTransmitter.Close(); } FOSCTransmitter = new OSCTransmitter(FTargetIP.ToString(), FTargetPort); FOSCTransmitter.Connect(); FLogger.Log(LogType.Debug, "connected to Kontrolleur on: " + FTargetIP.ToString() + ":" + FTargetPort.ToString()); } catch (Exception e) { FLogger.Log(LogType.Warning, "Kontrolleur: failed to open port " + FTargetPort.ToString()); FLogger.Log(LogType.Warning, "Kontrolleur: " + e.Message); } } } }
/// <summary> /// Connect the UDP transmitter using the port and IP specified above. /// </summary> /// <returns></returns> private bool connectTransmitter(String Host, String Port) { try { // Close any open connections. disconnectTransmitter(); // Reconnect with the new API. pUDPWriter = new OSCTransmitter(Host, Int32.Parse(Port)); pUDPWriter.Connect(); return(true); } catch (Exception pError) { // Tear down. try { this.disconnectTransmitter(); } catch { } // Report the error. System.Console.Error.WriteLine("TUIO Connection Error: " + pError.Message); return(false); } }
/// <summary> /// Connect the UDP transmitter using the port and IP specified above. /// </summary> /// <returns></returns> private bool connectTransmitter() { try { // Close any open connections. disconnectTransmitter(); // Reconnect with the new API. pUDPWriter = new OSCTransmitter(txtIPAddress.Text, Int32.Parse(txtPort.Text)); pUDPWriter.Connect(); return(true); } catch (Exception pError) { // Tear down. try { this.disconnectTransmitter(); } catch { } // Report the error. showMessage(pError.Message, MessageType.Error); return(false); } }
public void connect() { // Reconnect with the new API. pUDPWriter = new OSCTransmitter(WiiTUIO.Properties.Settings.Default.tuio_IP, WiiTUIO.Properties.Settings.Default.tuio_port); pUDPWriter.Connect(); if (OnConnect != null) { OnConnect(); } }
void Start() { localIpAdress = GetLocalIPAddress(); sender = new OSCTransmitter(targetIp, port); receiver = new OSCReceiverAsync(port); sender.Connect(); receiver.Connect(); receiver.Start(OnReceivedMessage); }
void StartOSCTransmitter() { var ip = TargetIPTextBox.Text.Trim(); try { var ipAddress = IPAddress.Parse(TargetIPTextBox.Text.Trim()); FOSCTransmitter = new OSCTransmitter(ip, (int)TargetPortNumberBox.Value); FOSCTransmitter.Connect(); } catch {} }
protected void DrawControllsInGame() { EditorGUILayout.BeginHorizontal("box"); GUI.color = _transmitter.IsAvailable ? Color.green : Color.red; var connection = GUILayout.Button(_transmitter.IsAvailable ? "Connected" : "Disconnected"); GUI.color = Color.yellow; EditorGUI.BeginDisabledGroup(!_transmitter.IsAvailable); var reconect = GUILayout.Button("Reconnect"); EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); if (connection) { if (_transmitter.IsAvailable) { _transmitter.Close(); } else { _transmitter.Connect(); } } if (reconect) { if (_transmitter.IsAvailable) { _transmitter.Close(); } _transmitter.Connect(); } }
protected void OnEnable() { _transmitter = target as OSCTransmitter; _remoteHostProperty = serializedObject.FindProperty("remoteHost"); _remotePortProperty = serializedObject.FindProperty("remotePort"); _autoConnectProperty = serializedObject.FindProperty("autoConnect"); _workInEditorProperty = serializedObject.FindProperty("workInEditor"); _mapBundleProperty = serializedObject.FindProperty("mapBundle"); _useBundleProperty = serializedObject.FindProperty("useBundle"); if (!Application.isPlaying && !_transmitter.IsAvaible && _workInEditorProperty.boolValue) { _transmitter.Connect(); } }
public PluginPage() { // The InitializeComponent() call is required for Windows Forms designer support. InitializeComponent(); //the actual pluginhost FPluginHost = new TPluginHost(); FPluginHost.OnPinCountChanged += new PinCountChangedHandler(PinCountChangedCB); FPluginHost.OnBeforeEvaluate += new EvaluateHandler(BeforeEvaluateCB); FPluginHost.OnAfterEvaluate += new EvaluateHandler(AfterEvaluateCB); FPluginHost.OnLog += new LogHandler(LogCB); FPluginHost.FPS = (int)FrameRateIO.Value; InputsPanel.Visible = false; InputsPanel.PinList = FPluginHost.Inputs; FSliceCountControls = new List <NumericUpDown>(); OutputsPanel.Visible = false; OutputsPanel.PinList = FPluginHost.Outputs; //initialize UDP/OSC FOSCAddress = "/" + OSCMessageIO.Text; try { FOSCTransmitter = new OSCTransmitter(TargetHostIO.Text, (int)TargetPortIO.Value); FOSCTransmitter.Connect(); } catch (Exception e) { DebugLog.Items.Add("UDP: failed to open port " + (int)TargetPortIO.Value); DebugLog.Items.Add("UDP: " + e.Message); } try { FOSCReceiver = new OSCReceiver((int)ReceivePortIO.Value); StartListeningOSC(); } catch (Exception e) { DebugLog.Items.Add("UDP: failed to open port " + (int)ReceivePortIO.Value); DebugLog.Items.Add("UDP: " + e.Message); } }
private void InitNetwork() { if (FIP != null) { try { if (FOSCTransmitter != null) { FOSCTransmitter.Close(); } FOSCTransmitter = new OSCTransmitter(FIP.ToString(), FTargetPort[0]); FOSCTransmitter.Connect(); } catch (Exception e) { FLogger.Log(LogType.Warning, "PinServer: failed to open port " + FTargetPort.ToString()); FLogger.Log(LogType.Warning, "PinServer: " + e.Message); } } }
void ThreadedFunction() { try { FClient = new OSCTransmitter(FPinInRemote[0], FPinInPort[0]); FClient.Connect(); FRunning = true; lock (FLockStatus) FStatus = "OK"; } catch (Exception e) { lock (FLockStatus) FStatus = e.Message; if (FClient != null) { FClient.Close(); } FRunning = false; return; } List <OSCPacket> copyList; while (FRunning) { lock (FLockPackets) { copyList = new List <OSCPacket>(FPacketList); FPacketList.Clear(); } foreach (var p in copyList) { FClient.Send(p); } } }
//private NetworkPresets myNetworkPresets; // Use this for initialization void Start() { // get IP values from single setting source GameObject myNetworkPresets = GameObject.Find("__NetworkPresets"); SendToIPAddress = myNetworkPresets.GetComponent <NetworkPresets>().SendToIPAddress; port = myNetworkPresets.GetComponent <NetworkPresets>().Port; Debug.Log("IP Address: " + SendToIPAddress + " Outgoing OSC Port: " + port); transmitter = new OSCTransmitter(SendToIPAddress, port); //myPacket. // Attempt to do everything in one line. transmitter.Connect(); connected = true; // Do something with bullet // Something went wrong, so lets get information about it. // Debug.Log(e.ToString()+"hello from the exception in UnityOSCTransmitter.cs"); // Do something knowing the bullet isn't on screen. // let's set some toggles to default values // Start Camera.main is ORTHO Camera.main.orthographic = true; Camera.main.orthographicSize = 2.61f; myMessage = new OSCMessage("/3/CameraTypeToggle/2/1", 1); // switch to the third tab in TouchOSC transmitter.Send(myMessage); Debug.Log("Camera set to orthographic. Scale = 2.61"); // just testing sending messages - this should go elsewhere or in some preset manager. //myMessage = new OSCMessage("/3"); // switch to the third tab in TouchOSC //transmitter.Send(myMessage); // just testing sending messages - this should go elsewhere or in some preset manager. //myMessage = new OSCMessage("/3/FadeToggle", 1); //transmitter.Send(myMessage); }
/// <summary> /// Connect the client and server. /// </summary> /// <param name="portNumber">Port number to listen on.</param> public void Connect(int portNumber) { connected = true; client.Connect(); server = new OSCReceiver(portNumber); server.Connect(); //server loop Task.Run(() => { while (connected) { var packet = server.Receive(); if (PacketReceived != null) { PacketReceived(this, packet); } } server.Close(); }); }
protected void OnEnable() { _transmitter = target as OSCTransmitter; _localHostCache = OSCUtilities.GetLocalHost(); _remoteHostProperty = serializedObject.FindProperty("_remoteHost"); _remotePortProperty = serializedObject.FindProperty("_remotePort"); _autoConnectProperty = serializedObject.FindProperty("_autoConnect"); _workInEditorProperty = serializedObject.FindProperty("_workInEditor"); _mapBundleProperty = serializedObject.FindProperty("_mapBundle"); _useBundleProperty = serializedObject.FindProperty("_useBundle"); _closeOnPauseProperty = serializedObject.FindProperty("_closeOnPause"); _sourceReceiverProperty = serializedObject.FindProperty("_localReceiver"); _localHostModeProperty = serializedObject.FindProperty("_localHostMode"); _localHostProperty = serializedObject.FindProperty("_localHost"); _localPortModeProperty = serializedObject.FindProperty("_localPortMode"); _localPortProperty = serializedObject.FindProperty("_localPort"); if (!Application.isPlaying && !_transmitter.IsStarted && _workInEditorProperty.boolValue) { _transmitter.Connect(); } }
void Connect() { Disconnect(); FConnection = new OSCTransmitter(FInAddress[0], 9000); FConnection.Connect(); }