Exemple #1
0
 /// <summary>
 ///     Used to start the server with a specific receive data callback
 /// </summary>
 protected void StartServer(ReceivedDataCallback callback)
 {
     _server.Receive      += callback;
     _server.OnConnection += (address, channel) => { channel.BeginReceive(); };
     _server.OnError      += (exception, connection) => _serverExecutor.Exceptions.Add(exception);
     _server.Open();
 }
Exemple #2
0
        public void BeginReceive(ReceivedDataCallback callback)
        {
            Receive += callback;
            foreach (var msg in UnreadMessages.DequeueAll())
            {
                NetworkEventLoop.Receive(msg, this);
            }

            BeginReceiveInternal();
        }
Exemple #3
0
        public void RegisterCallBack()
        {
            receivedDataCallback =
                (IntPtr pUserParam, IntPtr ptr, int data_rate, byte radio_strength, IntPtr cal_score_ptr, float battery, int hand_type, int radio_channel) =>
            {
                GCHandle          handle_consume = (GCHandle)pUserParam;
                VRTRIXDataWrapper objDataGlove   = (handle_consume.Target as VRTRIXDataWrapper);
                VRTRIX_Quat[]     quat           = new VRTRIX_Quat[16];
                MarshalUnmananagedArray2Struct <VRTRIX_Quat>(ptr, 16, out quat);
                for (int i = 0; i < 16; i++)
                {
                    objDataGlove.data[i] = new Quaternion(quat[i].qx, quat[i].qy, quat[i].qz, quat[i].qw);
                }
                objDataGlove.data_rate      = data_rate;
                objDataGlove.radio_strength = radio_strength;
                objDataGlove.battery        = battery;
                objDataGlove.hand_type      = (HANDTYPE)hand_type;
                objDataGlove.radio_channel  = radio_channel;
                Marshal.Copy(cal_score_ptr, objDataGlove.calscore, 0, 6);
            };

            receivedEventCallback =
                (IntPtr pUserParam, IntPtr pEvent) =>
            {
                GCHandle          handle_consume = (GCHandle)pUserParam;
                VRTRIXDataWrapper objDataGlove   = (handle_consume.Target as VRTRIXDataWrapper);
                VRTRIXGloveEvent  gloveEvent     = (VRTRIXGloveEvent)pEvent;
                if (gloveEvent == VRTRIXGloveEvent.VRTRIXGloveEvent_Connected)
                {
                    objDataGlove.stat = VRTRIXGloveStatus.NORMAL;
                    Debug.Log("VRTRIXGloveEvent_Connected");
                }
                else if (gloveEvent == VRTRIXGloveEvent.VRTRIXGloveEvent_Disconnected)
                {
                    objDataGlove.stat = VRTRIXGloveStatus.DISCONNECTED;
                    Debug.Log("VRTRIXGloveEvent_Disconnected");
                }
                else if (gloveEvent == VRTRIXGloveEvent.VRTRIXGloveEvent_ChannelHopping)
                {
                    Debug.Log("VRTRIXGloveEvent_ChannelHopping");
                }
            };

            if (sp != IntPtr.Zero)
            {
                GCHandle handle_reg = GCHandle.Alloc(this);
                IntPtr   pUserParam = (IntPtr)handle_reg;
                RegisterDataCallback(pUserParam, this.sp, receivedDataCallback);
                RegisterEventCallback(this.sp, receivedEventCallback);
            }
        }
Exemple #4
0
        public void BeginReceive(ReceivedDataCallback callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            if (Receiving)
            {
                return;
            }

            Receive  += callback;
            Receiving = true;
            BeginReceiveInternal();
        }
        public void receive(ReceivedDataCallback callback)
        {
            try
            {
                var state = new StateObject();
                state.workSocket         = socket;
                state.onCompleteCallback = callback;

                // Begin receiving data from the remote device
                socket.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0,
                                    new AsyncCallback(receiveCallback), state);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
        public void receivedData(HANDTYPE type)
        {
            receivedDataCallback =
                (IntPtr ptr, int data_rate, byte radio_strength, IntPtr cal_score_ptr) =>
            {
                VRTRIX_Quat[] quat = new VRTRIX_Quat[16];
                MarshalUnmananagedArray2Struct <VRTRIX_Quat>(ptr, 16, out quat);
                for (int i = 0; i < 16; i++)
                {
                    data[i] = new Quaternion(quat[i].qx, quat[i].qy, quat[i].qz, quat[i].qw);
                }
                this.data_rate      = data_rate;
                this.radio_strength = radio_strength;
                Marshal.Copy(cal_score_ptr, this.calscore, 0, 6);
            };

            if (this.sp != IntPtr.Zero)
            {
                RegisterDataCallback(this.sp, receivedDataCallback);
            }
        }
Exemple #7
0
 public void BeginReceive(ReceivedDataCallback callback)
 {
     Receive += callback;
 }
 public void BeginReceive(ReceivedDataCallback callback)
 {
     UnderlyingConnection.BeginReceive(OnMessage);
 }
Exemple #9
0
 public virtual AbstractBootstrap OnReceive(ReceivedDataCallback receivedDataCallback)
 {
     ReceivedData = receivedDataCallback;
     return(this);
 }
 public virtual AbstractBootstrap OnReceive(ReceivedDataCallback receivedDataCallback)
 {
     ReceivedData = receivedDataCallback;
     return this;
 }
Exemple #11
0
 public void BeginReceive(ReceivedDataCallback callback)
 {
     Receive += callback;
 }
Exemple #12
0
 public void BeginReceive(ReceivedDataCallback callback)
 {
     throw new NotImplementedException();
 }
Exemple #13
0
 public void BeginReceive(ReceivedDataCallback callback)
 {
     UnderlyingConnection.BeginReceive(OnMessage);
 }
 public static extern void RegisterDataCallback(IntPtr sp, ReceivedDataCallback receivedDataCallback);
        public void BeginReceive(ReceivedDataCallback callback)
        {
            if (callback == null) throw new ArgumentNullException("callback");
            if(Receiving) return;

            Receive += callback;
            Receiving = true;
            BeginReceiveInternal();
        }
Exemple #16
0
 /// <summary>
 ///     Used to start the server with a specific receive data callback
 /// </summary>
 protected void StartServer(ReceivedDataCallback callback)
 {
     _server.Receive += callback;
     _server.OnConnection += (address, channel) => { channel.BeginReceive(); };
     _server.OnError += (exception, connection) => _serverExecutor.Exceptions.Add(exception);
     _server.Open();
 }
 public void BeginReceive(ReceivedDataCallback callback)
 {
     Receive += callback;
     BeginReceiveInternal();
 }
        public void BeginReceive(ReceivedDataCallback callback)
        {
            Receive += callback;
            foreach (var msg in UnreadMessages.DequeueAll())
            {
                NetworkEventLoop.Receive(msg, this);
            }

            BeginReceiveInternal();
        }
Exemple #19
0
 public new ClientBootstrap OnReceive(ReceivedDataCallback receivedDataCallback)
 {
     base.OnReceive(receivedDataCallback);
     return this;
 }
Exemple #20
0
 public new ServerBootstrap OnReceive(ReceivedDataCallback receivedDataCallback)
 {
     base.OnReceive(receivedDataCallback);
     return(this);
 }
Exemple #21
0
 public void BeginReceive(ReceivedDataCallback callback)
 {
     throw new NotImplementedException();
 }