Example #1
0
        public void WriteMsg(CtkProtocolTrxMessage msg)
        {
            if (msg == null)
            {
                throw new ArgumentException("Paramter cannot be null");
            }
            var msgStr = msg.As <string>();

            if (msgStr != null)
            {
                var buff = Encoding.UTF8.GetBytes(msgStr);
                this.WriteBytes(buff, 0, buff.Length);
                return;
            }

            var msgBuffer = msg.As <CtkProtocolBufferMessage>();

            if (msgBuffer != null)
            {
                this.WriteBytes(msgBuffer.Buffer, msgBuffer.Offset, msgBuffer.Length);
                return;
            }

            var msgBytes = msg.As <byte[]>();

            if (msgBytes != null)
            {
                this.WriteBytes(msgBytes, 0, msgBytes.Length);
                return;
            }

            throw new ArgumentException("Cannot support this type: " + msg.ToString());
        }
Example #2
0
        /// <summary>
        /// 只支援 CtkWcfMessage
        /// </summary>
        /// <param name="msg"></param>
        public void WriteMsg(CtkProtocolTrxMessage msg)
        {
            var wcfmsg = msg.As <CtkWcfMessage>();

            if (wcfmsg != null)
            {
                this.activeWorkClient.CtkSend(msg.As <CtkWcfMessage>());
                return;
            }
            throw new ArgumentException("No support type");
        }
Example #3
0
 public void WriteMsg(CtkProtocolTrxMessage msg)
 {
     if (msg.Is <string>())
     {
         var buff = Encoding.UTF8.GetBytes(msg.As <string>());
         this.WriteBytes(buff, 0, buff.Length);
     }
     else if (msg.Is <CtkProtocolBufferMessage>())
     {
         var buff = msg.As <CtkProtocolBufferMessage>();
         this.WriteBytes(buff.Buffer, buff.Offset, buff.Length);
     }
     else
     {
         throw new ArgumentException("Not support type");
     }
 }
Example #4
0
 public void WriteMsg(CtkProtocolTrxMessage msg)
 {
     if (msg.As <string>() != null)
     {
         var buff = Encoding.UTF8.GetBytes(msg.As <string>());
         this.WriteBytes(buff, 0, buff.Length);
     }
     else if (msg.As <CxHsmsMessage>() != null)
     {
         var secsMsg = msg.As <CxHsmsMessage>();
         var buffer  = secsMsg.ToBytes();
         this.WriteBytes(buffer, 0, buffer.Length);
     }
     else
     {
         throw new ArgumentException("未定義該型別的寫入操作");
     }
 }
Example #5
0
 public void ReceiveMsg(CtkProtocolTrxMessage msg)
 {
     if (msg.Is <CtkProtocolBufferMessage>())
     {
         var buffer = msg.As <CtkProtocolBufferMessage>();
         this.ReceiveBytes(buffer.Buffer, buffer.Offset, buffer.Length);
     }
     else
     {
         throw new ArgumentException("Not support type");
     }
 }