示例#1
0
        public static int CreateCThread(int channel, Action <int, int, int> receiveCall)
        {
            if (createdThread.ContainsKey(channel))
            {
                return(-1000);
            }

            int re = sthread_create(channel);

            if (re >= 0)
            {
                CThreadContext context = new CThreadContext();
                context.channel     = channel;
                context.receiveCall = receiveCall;

                if (channel >= cthreads.Count)
                {
                    for (int i = cthreads.Count; i <= channel; i++)
                    {
                        cthreads.Add(null);
                    }
                }

                cthreads[channel] = context;
                createdThread.Add(channel, null);
            }

            return(re);
        }
示例#2
0
        public static void CThreadRun(int channel)
        {
            CThreadContext context = GetCThreadContext(channel);

            if (context == null)
            {
                return;
            }

            context.Send();
        }
示例#3
0
        public static int Receive(int channel, byte[] buf)
        {
            CThreadContext context = GetCThreadContext(channel);

            if (context == null)
            {
                return(-1);
            }
            context.Receive(buf);
            return(0);
        }
示例#4
0
        public static int SendMsg(int channel, int toChannel, int gID, int uID, SProto msg)
        {
            CThreadContext context = GetCThreadContext(channel);

            if (context == null)
            {
                return(-1);
            }

            context.AddMsg(toChannel, gID, uID, msg);
            return(0);
        }