public void SendToClient(MsgCode code, string body)
        {
            var text = MsgEncoding.Encode(code, body);

            swSender.WriteLine(text);
            swSender.Flush();
        }
Exemple #2
0
 void FC_onMsging(MsgCode obj)
 {
     if (obj == MsgCode.Volume_Query)
     {
         refresh();
     }
 }
        private void SendToServer(MsgCode code, string body)
        {
            var text = MsgEncoding.Encode(code, body);

            stwSender.WriteLine(text);
            stwSender.Flush();
        }
Exemple #4
0
        /// <summary>
        /// Submit transaction requist to jserv. This method is synchronized - not returned until callbacks been called.
        /// </summary>
        /// <param name="req"></param>
        /// <param name="onOk"></param>
        /// <param name="onErr"></param>
        public void CommitAsync(AnsonMsg req, OnOk onOk, OnError onErr = null, CancellationTokenSource waker = null)
        {
            Task t = Task.Run(async delegate
            {
                try
                {
                    HttpServClient httpClient = new HttpServClient();
                    AnsonMsg msg = await httpClient.Post(AnClient.ServUrl((Port)req.port), req);
                    MsgCode code = msg.code;

                    if (MsgCode.ok == code.code)
                    {
                        onOk.ok((AnsonResp)msg.Body(0));
                    }
                    else
                    {
                        if (onErr != null)
                        {
                            onErr.err(code, ((AnsonResp)msg.Body(0)).Msg());
                        }
                        else
                        {
                            Debug.WriteLine("Error: code: {0}\nerror: {1}",
                                            code, msg.ToString());
                        }
                    }
                }
                catch (Exception _) { }
                finally { if (waker != null)
                          {
                              waker.Cancel();
                          }
                }
            });
        }
Exemple #5
0
        public async Task Commit_async(AnsonMsg req, OnOk onOk, OnError onErr = null)
        {
            HttpServClient httpClient = new HttpServClient();
            AnsonMsg       msg        = await httpClient.Post(AnClient.ServUrl((Port)req.port), req);

            MsgCode code = msg.code;

            if (AnClient.console)
            {
                System.Console.Out.WriteLine(msg.ToString());
            }

            if (MsgCode.ok == code.code)
            {
                onOk.ok((AnsonResp)msg.Body(0));
            }
            else
            {
                if (onErr != null)
                {
                    onErr.err(code, ((AnsonResp)msg.Body(0)).Msg());
                }
                else
                {
                    System.Console.Error.WriteLine("code: {0}\nerror: {1}",
                                                   code, msg.ToString());
                }
            }
        }
Exemple #6
0
 public Message this[MsgCode code]
 {
     get
     {
         return(_messages[code]);
     }
 }
Exemple #7
0
 public void GetMenuItemDataModel(
     MenuCode menuCode,
     MsgCode msgCode,
     UIIcon iconCode,
     string padding,
     Action <MenuItemDataModel> onSuccess,
     Action <MenuItemDataModel> onError)
 {
     WrapErr.ToErrReport(9999, () => {
         ErrReport report;
         WrapErr.ToErrReport(out report, 9999, () => {
             onSuccess(new MenuItemDataModel()
             {
                 Code       = menuCode,
                 Display    = this.GetText(msgCode),
                 IconSource = this.IconSource(iconCode),
                 Padding    = padding,
             });
         });
         if (report.Code != 0)
         {
             WrapErr.SafeAction(() => {
                 onError.Invoke(new MenuItemDataModel()
                 {
                     Code       = menuCode,
                     Display    = "**NA**",
                     IconSource = "",
                     Padding    = padding,
                 });
             });
         }
     });
 }
Exemple #8
0
        /// <summary>
        /// Najde defaultní text daného kódu hlášky.
        /// Najde hlášku ve třídě <see cref="MsgCode"/>, vyhledá tam konstantu zadaného názvu, načte atribut dekorující danou konstantu,
        /// atribut typu <see cref="DefaultMessageTextAttribute"/>, načte jeho hodnotu <see cref="DefaultMessageTextAttribute.DefaultText"/>, a vrátí ji.
        /// </summary>
        /// <param name="messageCode"></param>
        /// <returns></returns>
        public static string GetMessageText(MsgCode messageCode)
        {
            if (_Messages == null)
            {
                _Messages = new Dictionary <MsgCode, string>();
            }
            string text = null;

            if (!_Messages.TryGetValue(messageCode, out text))
            {
                var msgField = typeof(MsgCode).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static).Where(f => f.Name == messageCode.ToString()).FirstOrDefault();
                if (msgField != null)
                {
                    var defTextAttr = msgField.GetCustomAttributes(typeof(DefaultMessageTextAttribute), true).Cast <DefaultMessageTextAttribute>().FirstOrDefault();
                    if (!(defTextAttr is null || String.IsNullOrEmpty(defTextAttr.DefaultText)))
                    {
                        text = defTextAttr.DefaultText;
                    }
                }

                // Pro daný kód si text uložím vždy, i když nebyl nalezen (=null) = abych jej příště jak osel nehledal znovu:
                lock (_Messages)
                {
                    if (!_Messages.ContainsKey(messageCode))
                    {
                        _Messages.Add(messageCode, text);
                    }
                }
            }
            return(text);
        }
Exemple #9
0
        public static string MsgCodeText(MsgCode msgCode)
        {
            var msg = "";

            msg = string.IsNullOrEmpty(msg) ? msgCode.ToString() : msg;
            return(msg);
        }
Exemple #10
0
 public static void RegisterLocalMessageHandler(MsgCode protocolCode, Action <byte[]> handler)
 {
     if (MsgCode.PveBattleResultMessage == protocolCode)
     {
         // Specifically, pve needs to request server data
         NetworkManager.RegisterServerMessageHandler(ServerType.GameServer, protocolCode, handler);
     }
     else if (!localMessageHandlers.ContainsKey(protocolCode))
     {
         localMessageHandlers.Add(protocolCode, handler);
     }
     else
     {
         if (localMessageHandlers[protocolCode] != null)
         {
             Delegate[] delegates = localMessageHandlers[protocolCode].GetInvocationList();
             foreach (Delegate del in delegates)
             {
                 if (del.Equals(handler))
                 {
                     return;
                 }
             }
         }
         localMessageHandlers[protocolCode] += handler;
     }
 }
Exemple #11
0
        void onmsg(MsgCode msg)
        {
            if (msg == MsgCode.Null)
            {
                return;
            }


            if (msg == MsgCode.User_Login)
            {
                // is user logined
                var user = FC.Get <User> (MsgCode.User_Login_Get);
                if (user != default(User))
                {
                    return;
                }

                var users  = FC.QueryUser();
                var retlen = 0;
                if (users.Length == 1)
                {
                    Msg_User_Login login = new Msg_User_Login();
                    login.user     = users[0];
                    login.password = "******";
                    FC.Send <Msg_User_Login> (MsgCode.User_Login, login, ref retlen);
                }
            }

            this.msg.Show(msg.ToString());
        }
Exemple #12
0
 private static string GetText(MsgCode code)
 {
     if (App.IsRunning)
     {
         return(App.GetText(code));
     }
     return(english.GetText(code));
 }
Exemple #13
0
 public void err(MsgCode code, string msg, string[] args = null)
 {
     if (AlbumContext.GetInstance().State() == ConnState.Disconnected)
     {
         ; // how to notify?
     }
     AlbumContext.GetInstance().State(ConnState.Online);
 }
Exemple #14
0
 public MessageRecord(MsgCode code)
 {
     Code       = code;
     Message    = MessageTable.Get()[Code];
     SourceFile = null;
     Line       = null;
     Pos        = null;
     Data       = null;
 }
Exemple #15
0
 public MessageRecord(MsgCode code, string sourceFile, int?line, int?pos, params object[] data)
 {
     Code       = code;
     Message    = MessageTable.Get()[code];
     SourceFile = sourceFile;
     Line       = line;
     Pos        = pos;
     Data       = data;
 }
        public void SendCredentials(LoginType type, string userID = "", string password = "")
        {
            loginType     = type;
            this.userID   = userID;
            this.password = password;

            byte[]  stream        = null;
            MsgCode serverChannel = MsgCode.LoginMessage;

            switch (type)
            {
            case LoginType.Guest:
            {
                return;
            }

            case LoginType.Login:
            {
                LoginC2S loginData = new LoginC2S();

                loginData.loginName = userID;
                loginData.password  = password;
                loginData.UDID      = DeviceUtil.Instance.GetDeviceUniqueIdentifier();
                loginData.MAC       = DeviceUtil.Instance.GetDeviceUniqueIdentifier();
                loginData.ip        = DeviceUtil.Instance.GetDeviceIP();

                stream        = ProtobufUtils.Serialize(loginData);
                serverChannel = MsgCode.LoginMessage;

                UILockManager.SetGroupState(UIEventGroup.Middle, UIEventState.WaitNetwork);

                break;
            }

            case LoginType.Register:
            {
                RegisterC2S register = new RegisterC2S();

                register.ip        = DeviceUtil.Instance.GetDeviceIP();
                register.MAC       = DeviceUtil.Instance.GetDeviceUniqueIdentifier();
                register.loginName = userID;
                register.passWord  = password;

                stream        = ProtobufUtils.Serialize(register);
                serverChannel = MsgCode.RegisterMessage;

                UILockManager.SetGroupState(UIEventGroup.Middle, UIEventState.WaitNetwork);

                break;
            }
            }

            Utils.DebugUtils.Log(Utils.DebugUtils.Type.Login, string.Format("SendCredentials {0} userID: {1} password: {2}", serverChannel.ToString(), userID, password));
            Utils.DebugUtils.Log(Utils.DebugUtils.Type.Login, string.Format("Sending {0} as {1} ", type == LoginType.Register ? "RegisterC2S" : "LoginC2S", serverChannel.ToString()));
            NetworkManager.SendRequest(serverChannel, stream);
        }
        //public static string OK { get { return GetTxt(MsgCode.Ok); } }
        //public static string Yes { get { return GetTxt(MsgCode.yes); } }
        //public static string No { get { return GetTxt(MsgCode.no); } }
        //public static string Language { get { return GetTxt(MsgCode.language); } }
        //public static string Start { get { return GetTxt(MsgCode.start); } }
        //public static string Stop { get { return GetTxt(MsgCode.stop); } }
        //public static string Command { get { return GetTxt(MsgCode.command); } }
        //public static string Commands { get { return GetTxt(MsgCode.commands); } }
        //public static string Response { get { return GetTxt(MsgCode.response); } }
        //public static string Discover { get { return GetTxt(MsgCode.Search); } }
        //public static string Info { get { return GetTxt(MsgCode.info); } }
        //public static string Terminators { get { return GetTxt(MsgCode.Terminators); } }
        //public static string EnterName { get { return GetTxt(MsgCode.EnterName); } }
        //public static string Continue { get { return GetTxt(MsgCode.Continue); } }
        //public  static string Configure { get { return GetTxt(MsgCode.Configure); } }
        //public static string PairedDevice { get { return GetTxt(MsgCode.PairedDevices); } }
        //public static string Pair { get { return GetTxt(MsgCode.Pair); } }
        //public static string UnPair { get { return GetTxt(MsgCode.Unpair); } }
        //public static string Password { get { return GetTxt(MsgCode.Password); } }
        //public static string HostName { get { return GetTxt(MsgCode.HostName); } }
        //public static string NetworkService { get { return GetTxt(MsgCode.NetworkService); } }
        //public static string Port { get { return GetTxt(MsgCode.Port); } }
        //public static string HostNameIp { get { return string.Format("{0}/IP", HostName); } }
        //public static string NetworkServicePort { get { return string.Format("{0}/{1}", NetworkService, Port); } }
        //public static string NetworkSecurityKey { get { return GetTxt(MsgCode.NetworkSecurityKey); } }
        //public static string Network { get { return GetTxt(MsgCode.Network); } }
        //public static string Socket { get { return GetTxt(MsgCode.Socket); } }
        //public static string Credentials { get { return GetTxt(MsgCode.Credentials); } }
        //public static string About { get { return GetTxt(MsgCode.About); } }
        //public static string Services { get { return GetTxt(MsgCode.Services); } }
        //public static string Service { get { return GetTxt(MsgCode.Service); } }
        //public static string Properties { get { return GetTxt(MsgCode.Properties); } }
        //public static string Vendor { get { return GetTxt(MsgCode.Vendor); } }
        //public static string Product { get { return GetTxt(MsgCode.Product); } }
        //public static string Default { get { return GetTxt(MsgCode.Default); } }
        //public static string Enabled { get { return GetTxt(MsgCode.Enabled); } }
        //public static string BaudRate { get { return GetTxt(MsgCode.BaudRate); } }
        //public static string DataBits { get { return GetTxt(MsgCode.DataBits); } }
        //public static string StopBits { get { return GetTxt(MsgCode.StopBits); } }
        //public static string Parity { get { return GetTxt(MsgCode.Parity); } }
        //public static string FlowControl { get { return GetTxt(MsgCode.FlowControl); } }
        //public static string Read { get { return GetTxt(MsgCode.Read); } }
        //public static string Write { get { return GetTxt(MsgCode.Write); } }
        //public static string Timeout { get { return GetTxt(MsgCode.Timeout); } }
        //public static string ReadTimeout { get { return GetTxt(MsgCode.ReadTimeout); } }
        //public static string WriteTimeout { get { return GetTxt(MsgCode.WriteTimeout); } }
        //public static string LogText { get { return GetTxt(MsgCode.Log); } }
        //public static string Ethernet { get { return GetTxt(MsgCode.Ethernet); } }
        //public static string Create { get { return GetTxt(MsgCode.Create); } }
        //public static string Clear { get { return GetTxt(MsgCode.Clear); } }
        //public static string ResetAll { get { return GetTxt(MsgCode.ResetAll); } }
        //public static string Settings { get { return GetTxt(MsgCode.Settings); } }
        //public static string NothingSelected { get { return GetTxt(MsgCode.NothingSelected); } }
        //public static string Characteristic { get { return GetTxt(MsgCode.Characteristic); } }
        //public static string Descriptor { get { return GetTxt(MsgCode.Descriptor); } }
        //public static string Email { get { return GetTxt(MsgCode.email); } }
        //public static string CrashReport { get { return GetTxt(MsgCode.CrashReport); } }
        //public static string Description { get { return GetTxt(MsgCode.Description); } }
        //public static string Address { get { return GetTxt(MsgCode.Address); } }


        //public static string BuildNumber {
        //    get {
        //        return App.Build;
        //    }
        //}


        ///// <summary>To access the user manual in the browser</summary>
        //public static string UserManualUri {
        //    get {
        //        return string.Format(@"file:///{0}", DI.Wrapper.UserManualFullFileName);
        //    }
        //}

        //public static string SupportlUri {
        //    get {
        //        return string.Format(@"mailto:[email protected]?subject=Multi Comm Terminal Support Question&body=App Build number:{0}", BuildNumber);
        //    }
        //}



        //#endregion

        #region Private

        private static string GetTxt(MsgCode code)
        {
            if (System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
            {
                // If in VS XMAL designer get text from the english language module
                return(designLanguage.GetMsg(code).Display);
            }
            // Dependency injector
            return(DI.W.GetText(code));
        }
Exemple #18
0
        void FC_onMsging(MsgCode obj)
        {
#if DEBUG
            msg.Show(obj.ToString());
#endif
            if (obj == MsgCode.Volume_Query)
            {
                queryVolume();
            }
        }
Exemple #19
0
        public string GetText(MsgCode code)
        {
            ErrReport report;
            string    msg = "ERR";

            WrapErr.ToErrReport(out report, 2000203, "Failure on GetText", () => {
                msg = this.languages.GetMsgDisplay(code);
            });
            return(msg);
        }
Exemple #20
0
        /// <summary>
        /// Vrátí lokalizovanou hlášku
        /// </summary>
        /// <param name="messageCode"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static string GetMessage(MsgCode messageCode, IEnumerable <object> parameters)
        {
            string text = GetMessageText(messageCode);

            if (text == null)
            {
                return(null);
            }
            return(String.Format(text, parameters));
        }
        public static void MessageAnalyze(MsgCode protocolCode, byte[] data)
        {
            DebugUtils.Log(DebugUtils.Type.MessageAnalyze, string.Format("send protocolCode {0} total length:{1}", protocolCode, data.Length));

            if (protocolCode == MsgCode.UpdateMessage)
            {
                UpdateC2S u = ProtobufUtils.Deserialize <UpdateC2S>(data);
                DebugUtils.LogWarning(DebugUtils.Type.MessageAnalyze, string.Format("operation: {0} total length:{1}", u.operation.opType, data.Length));
            }
        }
Exemple #22
0
 private static string GetTxt(MsgCode code)
 {
     try {
         lock (lockObj) {
             return(factory.CurrentLanguage.GetText(code));
         }
     }
     catch (Exception) {
         return("ERR");
     }
 }
 public static void SendRequest(MsgCode protocolCode, byte[] data, ClientType clientType = ClientType.Tcp, Action onRequestSuccess = null, Action onResquestFailed = null, int resendTimes = 1)
 {
     if (instance.currentClient != null)
     {
         instance.currentClient.SendRequest(protocolCode, data, clientType, onRequestSuccess, onResquestFailed, resendTimes);
     }
     else
     {
         DebugUtils.LogError(DebugUtils.Type.Network, string.Format("the current server {0} sent request to doesn't exist!", instance.currentServerType));
     }
 }
 public static void RemoveServerMessageHandler(MsgCode protocolCode, Action <byte[]> handler)
 {
     if (instance.currentClient != null)
     {
         instance.currentClient.RemoveServerMessageHandler(protocolCode, handler);
     }
     else
     {
         DebugUtils.LogError(DebugUtils.Type.Network, string.Format("the server {0} removed {1} handler from doesn't exist!", instance.currentServerType, protocolCode));
     }
 }
Exemple #25
0
        /// <summary>
        /// Login and return a client instance (with session managed by jserv).
        /// </summary>
        /// <param name="uid"></param>
        /// <paramref name="pswdPlain">password in plain</param>
        /// <param name="device"></param>
        /// <param name="onlogin"></param>
        /// <param name="err"></param>
        /// <throws>SQLException the request makes server generate wrong SQL.</throws>
        /// <throws>SemanticException Request can not parsed correctly</throws>
        /// <throws>GeneralSecurityException  other error</throws>
        /// <throws>Exception, most likely the network failed</throws>
        /// <return>null if failed, a SessionClient instance if login succeed.</return>
        public static async Task <SessionClient> Login(string uid, string pswdPlain, string device,
                                                       OnLogin onlogin, OnError err = null)
        {
            byte[] iv   = AESHelper.getRandom();
            string iv64 = AESHelper.Encode64(iv);

            if (uid == null || pswdPlain == null)
            {
                throw new SemanticException("user id and password can not be null.");
            }

            // string tk64 = AESHelper.Encrypt("-----------" + uid, pswdPlain, iv);
            string tk64 = AESHelper.Encrypt(uid, pswdPlain, iv);

            // formatLogin: {a: "login", logid: logId, pswd: tokenB64, iv: ivB64};
            // AnsonMsg<? extends AnsonBody> reqv11 = new AnsonMsg<AnQueryReq>(Port.session);;
            AnsonMsg reqv11 = AnSessionReq.formatLogin(uid, tk64, iv64, device);

            string         url        = ServUrl(new Port(Port.session));
            HttpServClient httpClient = new HttpServClient();

            SessionClient[] inst = new SessionClient[1];
            AnsonMsg        msg  = await httpClient.Post(url, reqv11).ConfigureAwait(false);

            MsgCode code = msg.code;

            if (code != null && MsgCode.ok == code.code)
            {
                // create a logged in client
                inst[0] = new SessionClient(((AnSessionResp)msg.Body()[0]).ssInf);
                if (onlogin != null)
                {
                    // onlogin.ok(new SessionClient(((AnSessionResp)msg.Body()[0]).ssInf));
                    onlogin.ok(inst[0]);
                }

                if (AnClient.console)
                {
                    Console.WriteLine(msg.ToString());
                }
            }
            else if (err != null)
            {
                err.err(new MsgCode(code.code), ((AnsonResp)msg.Body(0)).Msg());
            }
            else
            {
                throw new SemanticException(
                          "loging failed\ncode: {0}\nerror: {1}",
                          code, ((AnsonResp)msg.Body()[0]).Msg());
            }
            return(inst[0]);
        }
Exemple #26
0
        public void SendRequest(MsgCode protocolCode, byte[] data, ClientType type = ClientType.Tcp, Action onRequestSuccess = null, Action onResquestFailed = null, int resendTimes = 1)
        {
            DebugUtils.Log(DebugUtils.Type.Protocol, "try to send protocol " + protocolCode);

            if (notifySendThreadClosed)
            {
                DebugUtils.Log(DebugUtils.Type.Protocol, "Network message thread has been shutdown when trying to send protocol " + protocolCode);
                return;
            }

            if (type == ClientType.Tcp)
            {
                ClientTcpMessage message = new ClientTcpMessage((int)protocolCode, data, tcpSequence++);

                if (onRequestSuccess != null)
                {
                    message.OnRequestSuccess += onRequestSuccess;
                }

                if (onResquestFailed != null)
                {
                    message.OnRequestFailed += onResquestFailed;
                }

                tcpSendingQueue.Enqueue(message);

                NetworkAlert.StartWaiting(serverType, message, resendTimes);
            }
            else if (type == ClientType.Udp)
            {
                ClientUdpMessage[] messages = ClientUdpMessage.CreateUdpMessages((int)protocolCode, ref udpSequence, udpAck, data);
                int j = 0;
                for ( ; j < messages.Length; j++)
                {
                    udpSendingQueue.Enqueue(messages[j]);
                }

                if (onRequestSuccess != null)
                {
                    messages[j].OnRequestSuccess += onRequestSuccess;
                }

                if (onResquestFailed != null)
                {
                    messages[j].OnRequestFailed += onResquestFailed;
                }
            }
            else
            {
                DebugUtils.LogError(DebugUtils.Type.AsyncSocket, string.Format("There is no such client type {0} to send request!", type));
            }
        }
Exemple #27
0
        /// <summary>
        /// 返回错误操作提示
        /// </summary>
        /// <param name="code">错误编码</param>
        /// <param name="msg">消息提示</param>
        /// <returns></returns>
        public static APIResult GetErrorResult(MsgCode code, string msg = "")
        {
            if (string.IsNullOrWhiteSpace(msg))
            {
                msg = code.GetText();
            }

            return(new APIResult
            {
                code = ((int)code).ToString(),
                msg = msg
            });
        }
        public static void SendRequest(ServerType type, MsgCode protocolCode, byte[] data, ClientType clientType = ClientType.Tcp, Action onRequestSuccess = null, Action onResquestFailed = null, int resendTimes = 1)
        {
            NetworkClient client = null;

            instance.clients.TryGetValue(type, out client);
            if (client != null)
            {
                client.SendRequest(protocolCode, data, clientType, onRequestSuccess, onResquestFailed, resendTimes);
            }
            else
            {
                DebugUtils.LogError(DebugUtils.Type.Network, string.Format("the server {0} sent request to doesn't exist!", type));
            }
        }
        public static void RemoveServerMessageHandler(ServerType type, MsgCode protocolCode, Action <byte[]> handler)
        {
            NetworkClient client = null;

            instance.clients.TryGetValue(type, out client);
            if (client != null)
            {
                client.RemoveServerMessageHandler(protocolCode, handler);
            }
            else
            {
                DebugUtils.LogError(DebugUtils.Type.Network, string.Format("the server {0} removed {1} handler from doesn't exist!", type, protocolCode));
            }
        }
Exemple #30
0
 public void RemoveServerMessageHandler(MsgCode protocolCode, Action <byte[]> handler)
 {
     if (serverMessageHandlers.ContainsKey(protocolCode))
     {
         serverMessageHandlers[protocolCode] -= handler;
         if (serverMessageHandlers[protocolCode] == null)
         {
             serverMessageHandlers.Remove(protocolCode);
         }
     }
     else
     {
         DebugUtils.LogError(DebugUtils.Type.Protocol, "Remove an unregistered handler for protocol " + (int)protocolCode);
     }
 }
Exemple #31
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="code"></param>
        /// <param name="buffer"></param>
        /// <param name="count"></param>
        public void MultiplexWrite(MsgCode code, byte[] buffer, int count)
        {
            byte[] localBuffer = new byte[4096];
            int n = count;

            CheckSum.SIVAL(ref localBuffer, 0, (UInt32)(((MPLEX_BASE + (int)code) << 24) + count));

            if (n > localBuffer.Length - 4)
            {
                n = localBuffer.Length - 4;
            }

            Util.MemoryCopy(localBuffer, 4, buffer, 0, n);
            socketOut.Write(localBuffer, 0, n + 4);

            count -= n;
            if (count > 0)
            {
                socketOut.Write(buffer, n, count);
            }
        }
Exemple #32
0
		public void MplexWrite(MsgCode code, byte[] buf, int len)
		{
			byte[] buffer = new byte[4096];
			int n = len;

			CheckSum.SIVAL(ref buffer, 0, (UInt32)(((MPLEX_BASE + (int)code)<<24) + len));

			if (n > buffer.Length - 4)
				n = buffer.Length - 4;

			Util.MemCpy(buffer,4,buf,0, n);			
			sockOut.Write(buffer, 0, n+4);

			len -= n;			
			if (len > 0)
				sockOut.Write(buf, n, len);				
		}