Exemplo n.º 1
0
        // Request 一条消息,在服务器回复前,或超时前,如果再发这条消息,直接忽略。
        public void RequestNoRepeat(string op, Action <IWriteableBuffer> fun, Action <IReadableBuffer> callback)
        {
            if (pending == null)
            {
                pending = new HashSet <string>();
            }

            if (pending.Contains(op))
            {
                return;
            }

            pending.Add(op);

            NetUtils.Request(op, compName, fun,
                             (r) => {
                // 这一句放前面,否则如果callback出异常就悲剧了
                pending.Remove(op);
                if (callback != null)
                {
                    callback(r);
                }
            },
                             (connected) => {
                pending.Remove(op);
            },
                             conn);
        }
Exemplo n.º 2
0
Arquivo: Port.cs Projeto: Luxg520/L01
 // 发送请求并等待请求结果
 public void Request(string op, Action <IWriteableBuffer> fun, Action <IReadableBuffer> callback, Action <bool> onExpired)
 {
     NetUtils.Request(op, compName, fun, callback, onExpired, conn);
 }