Exemplo n.º 1
0
 public void ping()
 {
     if (isConnected && tcpStream.CanWrite)
     {
         List <byte> data    = RemoteFileUtil.packHeader(RemoteFile.Constants.RMF_CMD_START_ADDR, false);
         List <byte> payload = BitConverter.GetBytes(Constants.RMF_CMD_FILE_HEARTBEAT_REQ).ToList();
         data.AddRange(payload);
         send(data);
     }
 }
Exemplo n.º 2
0
        protected override void processMessage(Msg msg)
        {
            if (msg.msgType == RemoteFile.Constants.RMF_MSG_CONNECT)
            {
                throw new System.ArgumentException("Not applicable for c# version (handled in onConnected)");
            }
            else if (msg.msgType == RemoteFile.Constants.RMF_MSG_FILEINFO)
            {
                Apx.File file = (Apx.File)msg.msgData3;
                Console.WriteLine("processMessage, Name of file: " + file.name);

                List <byte> data    = RemoteFileUtil.packHeader(RemoteFile.Constants.RMF_CMD_START_ADDR, false);
                List <byte> payload = RemoteFileUtil.packFileInfo(file, "<");
                data.AddRange(payload);

                if (transmitHandler != null)
                {
                    transmitHandler.send(data);
                }
            }
            else if (msg.msgType == RemoteFile.Constants.RMF_MSG_WRITE_DATA)
            {
                uint        address = msg.msgData1;
                List <byte> data    = RemoteFileUtil.packHeader(address);
                List <byte> payload = (List <byte>)msg.msgData3;
                data.AddRange(payload);

                if (transmitHandler != null)
                {
                    transmitHandler.send(data);
                }
            }
            else if (msg.msgType == RemoteFile.Constants.RMF_MSG_FILEOPEN)
            {
                List <byte> data    = RemoteFileUtil.packHeader(RemoteFile.Constants.RMF_CMD_START_ADDR);
                List <byte> payload = RemoteFileUtil.packFileOpen(msg.msgData1);
                data.AddRange(payload);

                if (transmitHandler != null)
                {
                    transmitHandler.send(data);
                }
            }
            else
            {
                throw new System.ArgumentException("Unknown msgType");
            }
        }