Exemplo n.º 1
0
        // 发送消息给指定连接列表
        public static void Broadcast(string op, string toComponent, Action <IWriteableBuffer> fun, Connection c)
        {
            if (c == null)
            {
                return;
            }

            IWriteableBuffer buff = c.BeginSend(toComponent);

            buff.Write(op);
            if (fun != null)
            {
                fun(buff);
            }
            c.End(buff);
        }
Exemplo n.º 2
0
        // 发送请求给指定连接列表
        public static void Request(string op, string toComponent, Action <IWriteableBuffer> fun, Action <IReadableBuffer> callback, Action <bool> onExpired, Connection c)
        {
            if (c == null || !c.IsConnected)
            {
                if (onExpired != null)
                {
                    onExpired(false);
                }

                return;
            }

            IWriteableBuffer buff = c.BeginRequest(toComponent, callback, onExpired);

            buff.Write(op);
            if (fun != null)
            {
                fun(buff);
            }
            c.End(buff);
        }