Exemple #1
0
        public WiFiDeviceGateway(string ovrDeviceHostname, bool scentActivationLogging = false, int localhostDebugPort = 0)
        {
            _socketSender      = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            _ovrDeviceHostname = ovrDeviceHostname;
            _socketRecieveState.ovrHostname = _ovrDeviceHostname;
            _socketRecieveState.udpClient   = new UdpClient(0, AddressFamily.InterNetwork);

            var localIp = IPAddressExtensions.GetLocalIP();

            UnityEngine.Debug.LogFormat("<b>[OVR]</b> Local IP: {0}", localIp);

            if (scentActivationLogging)
            {
                _scentActivationLog = new NetworkLogging(localhostDebugPort);
            }

            _socketRecievePort = ((IPEndPoint)_socketRecieveState.udpClient.Client.LocalEndPoint).Port;

            // Setup for broadcasting hostname request from device
            MarshalHeader.Set(ref _checkConnectionPacket, MessageTypes.DEVICE_HOSTNAME_REQUEST, sizeof(ushort));
            _checkConnectionPacket[MarshalHeader.Size]     = (byte)_socketRecievePort;
            _checkConnectionPacket[MarshalHeader.Size + 1] = (byte)(_socketRecievePort >> 8);
            _onConnect    += OnConnect;
            _onDisconnect += OnDisconnect;
        }
Exemple #2
0
 public SerialDeviceGateway(bool scentActivationLogging = false, int localhostDebugPort = 0)
 {
     if (scentActivationLogging)
     {
         _odorantActivationLog = new NetworkLogging(localhostDebugPort);
     }
 }