Example #1
0
    public void SendFrame(SendObject frameData)
    {
        var param = new SendFramePara
        {
            Data = JsonUtility.ToJson(frameData),
        };

        Debug.Log(param.Data);
        Global.Room.SendFrame(param, (e) => {
            // TODO
            Debug.Log("send frame callback");
            Debug.Log(e);
        });
    }
Example #2
0
        public void Send(string message, int count, float delay)
        {
            if (_communicator == null)
            {
                return;
            }

            var data = new SendObject()
            {
                message = message,
                count   = count,
                delay   = delay
            };

            var task = new Task(SendAll, data);

            task.Start();
        }
        /// <summary>
        /// ќтправл¤ет событие выбора объекта
        /// </summary>
        /// <param name="li"></param>
        private void GetFileName(ListView li)
        {
            if (isSelectedLV(li))
            {
                string full_name   = li.SelectedItems[0].Tag.ToString();
                string object_name = li.SelectedItems[0].Text;
                string object_type = li.SelectedItems[0].Name;

                if (isSelectedLV(li))
                {
                    //TODO передача данных дл¤ шифровани¤
                    if (SendObject != null)
                    {
                        SendObject.Invoke(full_name, object_name, object_type);
                    }
                }
            }
            else
            {
                button_to_remote.Enabled = false;
            }
        }
Example #4
0
    void OnFrame(Frame frame)
    {
        var now = Time.realtimeSinceStartup;

        if (lastFrame > 0.0f)
        {
            Debug.Log(now - lastFrame);
        }
        lastFrame = now;
        if (frame.Items != null)
        {
            foreach (FrameItem item in frame.Items)
            {
                Debug.Log(item);
                //if (item.PlayerId != Player.Id)
                {
                    SendObject syncObject = JsonUtility.FromJson <SendObject>(item.Data);
                    switch (syncObject.method)
                    {
                    case "CommonResource":
                        Game.SetCommonResource(int.Parse(syncObject.value));
                        break;

                    case "HitPlayer":
                        Game.OnHitPlayer(syncObject.value);
                        break;

                    //case "SyncUp":
                    //    Game.SyncForPlayer(item.PlayerId, JsonUtility.FromJson<SyncObject>(syncObject.value));
                    //    break;
                    case "SomeOneJoin":
                        Game.OnSomeOneJoin();
                        break;
                    }
                }
            }
        }
    }
Example #5
0
 /// <summary>
 /// 根据通道索引发送Message
 /// </summary>
 /// <param name="Index">通道索(基于0)</param>
 /// <param name="message">要发送的消息结构体</param>
 /// <returns>状态码</returns>
 public static CANError SendChannelMessage(ref Int32 Index, ref SendObject message)
 {
     return(CanInteraction.CANSndMsg(Index, message));
 }
Example #6
0
        /// <summary>
        /// 重写发送,记录当前正在发送的数据实例
        /// </summary>
        /// <param name="io"></param>
        /// <param name="request"></param>
        /// <param name="frameType"></param>
        /// <returns></returns>
        public override int Send(IChannel io, IRequestInfo request, WebSocketFrameType frameType = WebSocketFrameType.Binary)
        {
            _sendObject = (SendObject)request.State;

            return(base.Send(io, request, frameType));
        }
Example #7
0
 /// <summary>
 /// 通讯未知,一般IO实例为空的时间调用此函数接口,例如没有打开串口或网络没有连接。
 /// </summary>
 public override void CommunicateNone()
 {
     _sendObject = null;
 }
Example #8
0
 /// <summary>
 /// 通讯中断,代表发送数据给设备后,在超时时间内没有返回任何数据信息
 /// </summary>
 /// <param name="info"></param>
 public override void CommunicateInterrupt(IResponseInfo info)
 {
     _sendObject = null;
     OnDeviceRuningLog("通讯中断");
 }
Example #9
0
 /// <summary>
 /// 通讯干扰,代表接收到数据,但是数据格式不符合协议标准。可能没有接收全数据,也可能受到电磁干扰。
 /// </summary>
 /// <param name="info"></param>
 public override void CommunicateError(IResponseInfo info)
 {
     _sendObject = null;
     OnDeviceRuningLog("通讯干扰");
 }
Example #10
0
 public static extern CANError CANSndMsg(Int32 nIndex, SendObject message);