WARNING_MSG() public static method

public static WARNING_MSG ( object s ) : void
s object
return void
Beispiel #1
0
        private static void fire_(Dictionary <string, List <Pair> > events, LinkedList <EventObj> firedEvents, string eventname, object[] args)
        {
            monitor_Enter(events);
            List <Pair> lst = null;

            if (!events.TryGetValue(eventname, out lst))
            {
                if (events == events_in)
                {
                    Dbg.WARNING_MSG("Event::fireIn: event(" + eventname + ") not found!");
                }
                else
                {
                    Dbg.WARNING_MSG("Event::fireOut: event(" + eventname + ") not found!");
                }

                monitor_Exit(events);
                return;
            }

            for (int i = 0; i < lst.Count; i++)
            {
                EventObj eobj = new EventObj();
                eobj.info = lst[i];
                eobj.args = args;
                firedEvents.AddLast(eobj);
            }

            monitor_Exit(events);
        }
Beispiel #2
0
        public bool connect(string ip, int port)
        {
            int count = 0;

__RETRY:
            reset();

            // Security.PrefetchSocketPolicy(ip, 843);
            socket_ = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            try
            {
                IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(ip), port);

                socket_.Connect(endpoint);
            }
            catch (Exception e)
            {
                MonoBehaviour.print(e.ToString());

                if (count < 3)
                {
                    Dbg.WARNING_MSG("connect(" + ip + ":" + port + ") is error, try=" + count + "!");
                    goto __RETRY;
                }

                return(false);
            }

            return(true);
        }
        private void _asyncReceive()
        {
            if (_networkInterface == null || !_networkInterface.valid())
            {
                Dbg.WARNING_MSG("PacketReceiver::_asyncReceive(): network interface invalid!");
                return;
            }

            var socket = _networkInterface.sock();

            while (true)
            {
                // 必须有空间可写,否则我们阻塞在线程中直到有空间为止
                int first = 0;
                int space = _free();

                while (space == 0)
                {
                    if (first > 0)
                    {
                        if (first > 1000)
                        {
                            Dbg.ERROR_MSG("PacketReceiver::_asyncReceive(): no space!");
                            Event.fireIn("_closeNetwork", new object[] { _networkInterface });
                            return;
                        }

                        Dbg.WARNING_MSG("PacketReceiver::_asyncReceive(): waiting for space, Please adjust 'RECV_BUFFER_MAX'! retries=" + first);
                        System.Threading.Thread.Sleep(5);
                    }

                    first += 1;
                    space  = _free();
                }

                int bytesRead = 0;
                try
                {
                    bytesRead = socket.Receive(_buffer, _wpos, space, 0);
                }
                catch (SocketException se)
                {
                    Dbg.ERROR_MSG(string.Format("PacketReceiver::_asyncReceive(): receive error, disconnect from '{0}'! error = '{1}'", socket.RemoteEndPoint, se));
                    Event.fireIn("_closeNetwork", new object[] { _networkInterface });
                    return;
                }

                if (bytesRead > 0)
                {
                    // 更新写位置
                    Interlocked.Add(ref _wpos, bytesRead);
                }
                else
                {
                    Dbg.WARNING_MSG(string.Format("PacketReceiver::_asyncReceive(): receive 0 bytes, disconnect from '{0}'!", socket.RemoteEndPoint));
                    Event.fireIn("_closeNetwork", new object[] { _networkInterface });
                    return;
                }
            }
        }
Beispiel #4
0
        public static void nocacheFireOut(string eventname, object[] args)
        {
            Dictionary <string, List <Pair> > events = events_out;

            monitor_Enter(events);
            List <Pair> lst = null;

            if (!events.TryGetValue(eventname, out lst))
            {
                if (events == events_in)
                {
                    Dbg.WARNING_MSG("Event::fireIn: event(" + eventname + ") not found!");
                }
                else
                {
                    Dbg.WARNING_MSG("Event::fireOut: event(" + eventname + ") not found!");
                }

                monitor_Exit(events);
                return;
            }

            for (int i = 0; i < lst.Count; i++)
            {
                EventObj eobj = new EventObj();
                eobj.info = lst[i];
                eobj.args = args;
                nocache_Fireout.AddLast(eobj);
            }

            monitor_Exit(events);
        }
        public void recv()
        {
            if (socket_ == null || socket_.Connected == false)
            {
                throw new ArgumentException("invalid socket!");
            }

            if (socket_.Poll(1000, SelectMode.SelectRead))
            {
                if (socket_ == null || socket_.Connected == false)
                {
                    Dbg.WARNING_MSG("invalid socket!");
                    return;
                }

                int successReceiveBytes = 0;

                try
                {
                    successReceiveBytes = socket_.Receive(_datas, MemoryStream.BUFFER_MAX, 0);
                }
                catch (SocketException err)
                {
                    if (err.ErrorCode == 10054 || err.ErrorCode == 10053)
                    {
                        Dbg.DEBUG_MSG(string.Format("NetworkInterface::recv(): disable connect!"));
                        if (socket_ != null && socket_.Connected)
                        {
                            socket_.Close();
                        }
                        socket_ = null;
                        Event.fire("onDisableConnect", new object[] {});
                    }
                    else
                    {
                        Dbg.ERROR_MSG(string.Format("NetworkInterface::recv(): socket error(" + err.ErrorCode + ")!"));
                    }
                }

                if (successReceiveBytes > 0)
                {
                    //	Dbg.DEBUG_MSG(string.Format("NetworkInterface::recv(): size={0}!", successReceiveBytes));
                }
                else if (successReceiveBytes == 0)
                {
                    Dbg.DEBUG_MSG(string.Format("NetworkInterface::recv(): disable connect!"));
                    if (socket_ != null && socket_.Connected)
                    {
                        socket_.Close();
                    }
                    socket_ = null;
                }
                else
                {
                    Dbg.ERROR_MSG(string.Format("NetworkInterface::recv(): socket error!"));
                }

                msgReader.process(_datas, (MessageLength)successReceiveBytes);
            }
        }
        public void startRecv()
        {
            // 必须有空间可写,否则我们阻塞在线程中直到有空间为止
            int first = 0;
            int space = _free();

            while (space == 0)
            {
                if (first > 0)
                {
                    Dbg.WARNING_MSG("PacketReceiver::startRecv(): waiting for space! retries=" + first);
                    System.Threading.Thread.Sleep(5);
                }

                first += 1;
                space  = _free();
            }

            try
            {
                _networkInterface.sock().BeginReceive(_buffer, _wpos, space, 0,
                                                      new AsyncCallback(_onRecv), this);
            }
            catch (Exception e)
            {
                Dbg.ERROR_MSG("PacketReceiver::startRecv(): call ReceiveAsync() is err: " + e.ToString());
                _networkInterface.close();
            }
        }
Beispiel #7
0
        public void startRecv()
        {
            // 必须有空间可写,否则我们阻塞在线程中直到有空间为止
            int first = 0;
            int space = _free();

            while (space == 0)
            {
                if (first > 0)
                {
                    if (first > 1000)
                    {
                        throw new Exception("PacketReceiver::startRecv(): no space!");
                    }

                    Dbg.WARNING_MSG("PacketReceiver::startRecv(): waiting for space, Please adjust 'RECV_BUFFER_MAX'! retries=" + first);
                    System.Threading.Thread.Sleep(5);
                }

                first += 1;
                space  = _free();
            }

            try
            {
                _networkInterface.sock().BeginReceive(_buffer, _wpos, space, 0,
                                                      _asyncCallback, this);
            }
            catch (Exception e)
            {
                Dbg.ERROR_MSG("PacketReceiver::startRecv(): call ReceiveAsync() is err: " + e.ToString());
                Event.fireIn("_closeNetwork", new object[] { _networkInterface });
            }
        }
Beispiel #8
0
        public bool connect(string ip, int port)
        {
            int count = 0;

            Regex rx = new Regex(@"((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))");

            if (rx.IsMatch(ip))
            {
            }
            else
            {
                IPHostEntry ipHost = Dns.GetHostEntry(ip);
                ip = ipHost.AddressList[0].ToString();
            }
__RETRY:
            reset();
            TimeoutObject.Reset();

            // Security.PrefetchSocketPolicy(ip, 843);
            socket_ = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            socket_.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, MemoryStream.BUFFER_MAX);

            try
            {
                IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(ip), port);

                socket_.BeginConnect(endpoint, new AsyncCallback(connectCB), socket_);

                if (TimeoutObject.WaitOne(10000))
                {
                }
                else
                {
                    reset();
                }
            }
            catch (Exception e)
            {
                Dbg.WARNING_MSG(e.ToString());

                if (count < 3)
                {
                    Dbg.WARNING_MSG("connect(" + ip + ":" + port + ") is error, try=" + (count++) + "!");
                    goto __RETRY;
                }

                return(false);
            }

            if (!valid())
            {
                Event.fireAll("onConnectStatus", new object[] { false });
                return(false);
            }

            Event.fireAll("onConnectStatus", new object[] { true });
            return(true);
        }
        public void end()
        {
            System.TimeSpan time = System.DateTime.Now - startTime;

            if (time.TotalMilliseconds >= 100)
            {
                Dbg.WARNING_MSG("Profile::profile(): '" + _name + "' took " + time.TotalMilliseconds + " ms");
            }
        }
Beispiel #10
0
        public void process()
        {
            while (!isbreak)
            {
                networkInterface_.process();
            }

            Dbg.WARNING_MSG("KBEngine::process(): break!");
        }
Beispiel #11
0
        public bool connect(string ip, int port)
        {
            int count = 0;

__RETRY:
            reset();
            TimeoutObject.Reset();

            // Security.PrefetchSocketPolicy(ip, 843);
            socket_ = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            socket_.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, MemoryStream.BUFFER_MAX);

            try
            {
                IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(ip), port);

                socket_.BeginConnect(endpoint, new AsyncCallback(connectCB), socket_);

                if (TimeoutObject.WaitOne(10000))
                {
                    if (valid())
                    {
                    }
                    else
                    {
                        ChuMeng.MyEventSystem.myEventSystem.PushEvent(ChuMeng.MyEvent.EventType.ReConnect);
                    }
                }
                else
                {
                    reset();
                }
            }
            catch (Exception e)
            {
                Dbg.WARNING_MSG(e.ToString());

                if (count < 3)
                {
                    Dbg.WARNING_MSG("connect(" + ip + ":" + port + ") is error, try=" + (count++) + "!");
                    goto __RETRY;
                }

                return(false);
            }

            if (!valid())
            {
                return(false);
            }

            return(true);
        }
Beispiel #12
0
        protected override void _asyncSend()
        {
            if (_networkInterface == null || !_networkInterface.valid())
            {
                Dbg.WARNING_MSG("PacketSenderTCP::_asyncSend(): network interface invalid!");
                return;
            }

            var socket = _networkInterface.sock();

            while (true)
            {
                Monitor.Enter(_sending);

                int sendSize = _wpos - _spos;
                int t_spos   = _spos % _buffer.Length;
                if (t_spos == 0)
                {
                    t_spos = sendSize;
                }

                if (sendSize > _buffer.Length - t_spos)
                {
                    sendSize = _buffer.Length - t_spos;
                }

                int bytesSent = 0;
                try
                {
                    bytesSent = socket.Send(_buffer, _spos % _buffer.Length, sendSize, 0);
                }
                catch (SocketException se)
                {
                    Dbg.ERROR_MSG(string.Format("PacketSenderTCP::_asyncSend(): send data error, disconnect from '{0}'! error = '{1}'", socket.RemoteEndPoint, se));
                    Event.fireIn("_closeNetwork", new object[] { _networkInterface });

                    Monitor.Exit(_sending);
                    return;
                }

                _spos += bytesSent;

                // 所有数据发送完毕了
                if (_spos == _wpos)
                {
                    _sending = false;
                    Monitor.Exit(_sending);
                    return;
                }

                Monitor.Exit(_sending);
            }
        }
Beispiel #13
0
        public override void process()
        {
            Socket socket = _networkInterface.sock();

            while (socket.Available > 0)
            {
                int length = 0;

                try
                {
                    length = socket.Receive(_buffer);
                }
                catch (Exception e)
                {
                    Dbg.ERROR_MSG("PacketReceiverKCP::process: " + e.ToString());
                    Event.fireIn("_closeNetwork", new object[] { _networkInterface });
                    return;
                }

                if (length <= 0)
                {
                    Dbg.WARNING_MSG("PacketReceiverKCP::_asyncReceive(): KCP Receive <= 0!");
                    return;
                }

                ((NetworkInterfaceKCP)_networkInterface).nextTickKcpUpdate = 0;
                if (kcp_.Input(_buffer, 0, length) < 0)
                {
                    Dbg.WARNING_MSG(string.Format("PacketReceiverKCP::_asyncReceive(): KCP Input get {0}!", length));
                    return;
                }

                while (true)
                {
                    length = kcp_.Recv(_buffer, 0, _buffer.Length);
                    if (length < 0)
                    {
                        break;
                    }

                    if (_networkInterface.fileter() != null)
                    {
                        _networkInterface.fileter().recv(_messageReader, _buffer, 0, (MessageLengthEx)length);
                    }
                    else
                    {
                        _messageReader.process(_buffer, 0, (MessageLengthEx)length);
                    }
                }
            }
        }
        void _asyncSend()
        {
            if (_networkInterface == null || !_networkInterface.valid())
            {
                Dbg.WARNING_MSG("PacketSender::_asyncSend(): network interface invalid!");
                return;
            }

            var socket = _networkInterface.sock();

            while (true)
            {
                int sendSize = Interlocked.Add(ref _wpos, 0) - _spos;
                int t_spos   = _spos % _buffer.Length;
                if (t_spos == 0)
                {
                    t_spos = sendSize;
                }

                if (sendSize > _buffer.Length - t_spos)
                {
                    sendSize = _buffer.Length - t_spos;
                }

                int bytesSent = 0;
                try
                {
                    bytesSent = socket.Send(_buffer, _spos % _buffer.Length, sendSize, 0);
                }
                catch (SocketException se)
                {
                    Dbg.ERROR_MSG(string.Format("PacketSender::_asyncSend(): send data error, disconnect from '{0}'! error = '{1}'", socket.RemoteEndPoint, se));
                    Event.fireIn("_closeNetwork", new object[] { _networkInterface });
                    return;
                }

                int spos = Interlocked.Add(ref _spos, bytesSent);

                // 所有数据发送完毕了
                if (spos == Interlocked.Add(ref _wpos, 0))
                {
                    Interlocked.Exchange(ref _sending, 0);
                    return;
                }
            }
        }
Beispiel #15
0
        private static void _onRecv(IAsyncResult ar)
        {
            // Retrieve the socket from the state object.
            PacketReceiver state = (PacketReceiver)ar.AsyncState;

            try
            {
                // 由于多线程问题,networkInterface可能已被丢弃了
                // 例如:在连接loginapp之后自动开始连接到baseapp之前会先关闭并丢弃networkInterface
                if (!state.networkInterface().valid())
                {
                    return;
                }

                Socket client = state.networkInterface().sock();

                // Read data from the remote device.
                int bytesRead = client.EndReceive(ar);

                if (bytesRead > 0)
                {
                    // 更新写位置
                    Interlocked.Add(ref state._wpos, bytesRead);
                    state.startRecv();
                }
                else
                {
                    if (bytesRead == 0)
                    {
                        Dbg.WARNING_MSG(string.Format("PacketReceiver::_processRecved(): disconnect!"));
                        Event.fireIn("_closeNetwork", new object[] { state.networkInterface() });
                        return;
                    }
                    else
                    {
                        state.startRecv();
                    }
                }
            }
            catch (Exception e)
            {
                Dbg.ERROR_MSG(string.Format("PacketReceiver::_processRecved(): is error({0})!", e.ToString()));
                Event.fireIn("_closeNetwork", new object[] { state.networkInterface() });
            }
        }
        public override void process()
        {
            Socket socket = _networkInterface.sock();

            while (socket.Available > 0)
            {
                int length = 0;

                try
                {
                    length = socket.Receive(_buffer);
                }
                catch (Exception e)
                {
                    Dbg.ERROR_MSG("PacketReceiverKCP::process: " + e.ToString());
                    continue;
                }

                if (length <= 0)
                {
                    Dbg.WARNING_MSG("PacketReceiverKCP::_asyncReceive(): KCP Receive <= 0!");
                    return;
                }

                if (kcp_.Input(_buffer, 0, length) < 0)
                {
                    Dbg.WARNING_MSG(string.Format("PacketReceiverKCP::_asyncReceive(): KCP Input get {0}!", length));
                    return;
                }

                while (true)
                {
                    length = kcp_.Recv(_buffer, 0, _buffer.Length);
                    if (length <= 0)
                    {
                        break;
                    }

                    _messageReader.process(_buffer, 0, (MessageLengthEx)length);
                }
            }
        }
Beispiel #17
0
        public bool connect(string ip, int port)
        {
            int count = 0;

__RETRY:
            reset();
            TimeoutObject.Reset();

            // Security.PrefetchSocketPolicy(ip, 843);
            socket_ = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            try
            {
                IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(ip), port);

                socket_.BeginConnect(endpoint, new AsyncCallback(connectCB), socket_);

                if (TimeoutObject.WaitOne(10000))
                {
                }
                else
                {
                    reset();
                }
            }
            catch (Exception e)
            {
                Dbg.WARNING_MSG(e.ToString());

                if (count < 3)
                {
                    Dbg.WARNING_MSG("connect(" + ip + ":" + port + ") is error, try=" + (count++) + "!");
                    goto __RETRY;
                }

                return(false);
            }

            return(valid());
        }
Beispiel #18
0
        public void destroy()
        {
            Dbg.WARNING_MSG("KBEngine::destroy()");
            isbreak = true;

            int i = 0;

            while (!kbethread.over && i < 50)
            {
                Thread.Sleep(1);
                i += 1;
            }

            if (t_ != null)
            {
                t_.Abort();
            }

            t_ = null;

            reset();
        }
Beispiel #19
0
        public static System.Reflection.MethodInfo bindwriter(Byte argType)
        {
            Type writer = typeof(Bundle);

            System.Reflection.MethodInfo info = null;

            if (argType == EntityDef.datatype2id["UINT8"])
            {
                info = writer.GetMethod("writeUint8");
            }
            else if (argType == EntityDef.datatype2id["UINT16"])
            {
                info = writer.GetMethod("writeUint16");
            }
            else if (argType == EntityDef.datatype2id["UINT32"])
            {
                info = writer.GetMethod("writeUint32");
            }
            else if (argType == EntityDef.datatype2id["UINT64"])
            {
                info = writer.GetMethod("writeUint64");
            }
            else if (argType == EntityDef.datatype2id["INT8"])
            {
                info = writer.GetMethod("writeInt8");
            }
            else if (argType == EntityDef.datatype2id["INT16"])
            {
                info = writer.GetMethod("writeInt16");
            }
            else if (argType == EntityDef.datatype2id["INT32"])
            {
                info = writer.GetMethod("writeInt32");
            }
            else if (argType == EntityDef.datatype2id["INT64"])
            {
                info = writer.GetMethod("writeInt64");
            }
            else if (argType == EntityDef.datatype2id["FLOAT"])
            {
                info = writer.GetMethod("writeFloat");
            }
            else if (argType == EntityDef.datatype2id["DOUBLE"])
            {
                info = writer.GetMethod("writeDouble");
            }
            else if (argType == EntityDef.datatype2id["STRING"])
            {
                info = writer.GetMethod("writeString");
            }
            else if (argType == EntityDef.datatype2id["FIXED_DICT"])
            {
                info = writer.GetMethod("writeStream");
            }
            else if (argType == EntityDef.datatype2id["ARRAY"])
            {
                info = writer.GetMethod("writeStream");
            }
            else
            {
                info = writer.GetMethod("writeStream");
            }

            if (info == null)
            {
                Dbg.WARNING_MSG("StreamRWBinder:: bindwriter(" + argType + ") is error!");
            }

            return(info);
        }
Beispiel #20
0
        public override void process(byte[] datas, MessageLengthEx offset, MessageLengthEx length)
        {
            MessageLengthEx totallen = offset;

            while (length > 0 && expectSize > 0)
            {
                if (state == READ_STATE.READ_STATE_MSGID)
                {
                    if (length >= expectSize)
                    {
                        Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize);
                        totallen    += expectSize;
                        stream.wpos += (int)expectSize;
                        length      -= expectSize;
                        msgid        = stream.readUint16();
                        stream.clear();

                        Message msg = Messages.clientMessages[msgid];

                        if (msg.msglen == -1)
                        {
                            state      = READ_STATE.READ_STATE_MSGLEN;
                            expectSize = 2;
                        }
                        else if (msg.msglen == 0)
                        {
                            // 如果是0个参数的消息,那么没有后续内容可读了,处理本条消息并且直接跳到下一条消息
                                                        #if UNITY_EDITOR
                            Dbg.profileStart(msg.name);
                                                        #endif

                            msg.handleMessage(stream);

                                                        #if UNITY_EDITOR
                            Dbg.profileEnd(msg.name);
                                                        #endif

                            state      = READ_STATE.READ_STATE_MSGID;
                            expectSize = 2;
                        }
                        else
                        {
                            expectSize = (MessageLengthEx)msg.msglen;
                            state      = READ_STATE.READ_STATE_BODY;
                        }
                    }
                    else
                    {
                        Array.Copy(datas, totallen, stream.data(), stream.wpos, length);
                        stream.wpos += (int)length;
                        expectSize  -= length;
                        break;
                    }
                }
                else if (state == READ_STATE.READ_STATE_MSGLEN)
                {
                    if (length >= expectSize)
                    {
                        Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize);
                        totallen    += expectSize;
                        stream.wpos += (int)expectSize;
                        length      -= expectSize;

                        msglen = stream.readUint16();
                        stream.clear();

                        // 长度扩展
                        if (msglen >= 65535)
                        {
                            state      = READ_STATE.READ_STATE_MSGLEN_EX;
                            expectSize = 4;
                        }
                        else
                        {
                            state      = READ_STATE.READ_STATE_BODY;
                            expectSize = msglen;
                        }
                    }
                    else
                    {
                        Array.Copy(datas, totallen, stream.data(), stream.wpos, length);
                        stream.wpos += (int)length;
                        expectSize  -= length;
                        break;
                    }
                }
                else if (state == READ_STATE.READ_STATE_MSGLEN_EX)
                {
                    if (length >= expectSize)
                    {
                        Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize);
                        totallen    += expectSize;
                        stream.wpos += (int)expectSize;
                        length      -= expectSize;

                        expectSize = stream.readUint32();
                        stream.clear();

                        state = READ_STATE.READ_STATE_BODY;
                    }
                    else
                    {
                        Array.Copy(datas, totallen, stream.data(), stream.wpos, length);
                        stream.wpos += (int)length;
                        expectSize  -= length;
                        break;
                    }
                }
                else if (state == READ_STATE.READ_STATE_BODY)
                {
                    if (length >= expectSize)
                    {
                        stream.append(datas, totallen, expectSize);
                        totallen += expectSize;
                        length   -= expectSize;

                        int     frpos = stream.rpos + (int)expectSize;
                        Message msg   = Messages.clientMessages[msgid];

#if UNITY_EDITOR
                        Dbg.profileStart(msg.name);
#endif

                        msg.handleMessage(stream);
#if UNITY_EDITOR
                        Dbg.profileEnd(msg.name);
#endif

                        if (expectSize > 0 && frpos != stream.rpos)
                        {
                            Dbg.WARNING_MSG("MessageReaderTCP::process(" + msg.name + "): rpos(" + stream.rpos + ") invalid, expect="
                                            + frpos + ". msgID=" + msgid + ", msglen=" + expectSize + ".");
                        }

                        stream.clear();

                        state      = READ_STATE.READ_STATE_MSGID;
                        expectSize = 2;
                    }
                    else
                    {
                        stream.append(datas, totallen, length);
                        expectSize -= length;
                        break;
                    }
                }
            }
        }
Beispiel #21
0
        public static System.Reflection.MethodInfo bindReader(Byte argType)
        {
            Type reader = typeof(MemoryStream);

            System.Reflection.MethodInfo info = null;

            if (argType == EntityDef.datatype2id["UINT8"])
            {
                info = reader.GetMethod("readUint8");
            }
            else if (argType == EntityDef.datatype2id["UINT16"])
            {
                info = reader.GetMethod("readUint16");
            }
            else if (argType == EntityDef.datatype2id["UINT32"])
            {
                info = reader.GetMethod("readUint32");
            }
            else if (argType == EntityDef.datatype2id["UINT64"])
            {
                info = reader.GetMethod("readUint64");
            }
            else if (argType == EntityDef.datatype2id["INT8"])
            {
                info = reader.GetMethod("readInt8");
            }
            else if (argType == EntityDef.datatype2id["INT16"])
            {
                info = reader.GetMethod("readInt16");
            }
            else if (argType == EntityDef.datatype2id["INT32"])
            {
                info = reader.GetMethod("readInt32");
            }
            else if (argType == EntityDef.datatype2id["INT64"])
            {
                info = reader.GetMethod("readInt64");
            }
            else if (argType == EntityDef.datatype2id["FLOAT"])
            {
                info = reader.GetMethod("readFloat");
            }
            else if (argType == EntityDef.datatype2id["DOUBLE"])
            {
                info = reader.GetMethod("readDouble");
            }
            else if (argType == EntityDef.datatype2id["STRING"])
            {
                info = reader.GetMethod("readString");
            }
            else if (argType == EntityDef.datatype2id["PYTHON"])
            {
                info = reader.GetMethod("readStream");
            }
            else if (argType == EntityDef.datatype2id["VECTOR2"])
            {
                info = reader.GetMethod("readStream");
            }
            else if (argType == EntityDef.datatype2id["VECTOR3"])
            {
                info = reader.GetMethod("readStream");
            }
            else if (argType == EntityDef.datatype2id["VECTOR4"])
            {
                info = reader.GetMethod("readStream");
            }
            else if (argType == EntityDef.datatype2id["BLOB"])
            {
                info = reader.GetMethod("readStream");
            }
            else if (argType == EntityDef.datatype2id["UNICODE"])
            {
                info = reader.GetMethod("readStream");
            }
            else if (argType == EntityDef.datatype2id["FIXED_DICT"])
            {
                info = reader.GetMethod("readStream");
            }
            else if (argType == EntityDef.datatype2id["ARRAY"])
            {
                info = reader.GetMethod("readStream");
            }
            else
            {
                info = reader.GetMethod("readStream");
            }

            if (info == null)
            {
                Dbg.WARNING_MSG("StreamRWBinder:: bindReader(" + argType + ") is error!");
            }

            return(info);
        }