Example #1
0
        private void BinaryInputOffsetHandler(byte[] data, int offset, int count, SocketAsyncEventArgs socketAsync)
        {
            try
            {
                ASyncToken tmp = socketAsync.UserToken as ASyncToken;

                if (tmp != null)
                {
                    tmp.Write(data, offset, count);
                }
                else if (count >= 8 && data[offset] == 0xFF && data[offset + 1] == 0xFE && data[offset + 5] == 0xCE &&
                         data[offset + 7] == 0xED)
                {
                    var token = NewASyncToken(socketAsync);
                    socketAsync.UserToken = token;

                    if (count > 8)
                    {
                        byte[] bakdata = new byte[count - 8];
                        Buffer.BlockCopy(data, offset + 8, bakdata, 0, bakdata.Length);

                        token.Write(bakdata, 0, bakdata.Length);
                    }
                }
            }
            catch (Exception er)
            {
                LogAction.Log(LogType.Err, er.ToString(), er);
            }
        }
Example #2
0
 public AsyncCalls(ILoggerFactory loggerFactory, ASyncToken token, Fiber fiber)
 {
     this.AsyncUser           = token;
     AsyncUser.UserDisconnect = (a, b) => this.UserDisconnect?.Invoke(a, b);
     this._fiber = fiber;
     FodyDir     = new Dictionary <Type, Type>();
     Log         = new DefaultLog(loggerFactory.CreateLogger <AsyncCalls>());
 }
Example #3
0
 public AsyncCalls(long id, int cmd, ASyncToken token, MethodInfo method, object[] args, bool ishavereturn)
 {
     IsHaveReturn = ishavereturn;
     Method       = method;
     Args         = args;
     AsyncUser    = token;
     Id           = id;
 }
Example #4
0
        /// <summary>
        /// 创建注册 ASyncToken
        /// </summary>
        /// <param name="socketAsync"></param>
        /// <returns></returns>
        private ASyncToken NewASyncToken(SocketAsyncEventArgs socketAsync, ZYNetRingBufferPool stream, long sessionkey)
        {
            ASyncToken tmp = new ASyncToken(this.LoggerFactory, socketAsync, this, sessionkey, stream)
            {
                ExceptionOut = this.ExceptionOut
            };

            return(tmp);
        }
Example #5
0
 public AsyncCalls(long id, int cmd, ASyncToken token, object implement, MethodInfo method, object[] args, bool ishavereturn)
 {
     Controller   = implement;
     IsHaveReturn = ishavereturn;
     Method       = method;
     Args         = args;
     AsyncUser    = token;
     Id           = id;
     FodyDir      = new Dictionary <Type, Type>();
 }
Example #6
0
        private void MessageInputHandler(string message, SocketAsyncEventArgs socketAsync, int erorr)
        {
            if (socketAsync.UserToken != null)
            {
                ASyncToken tmp = socketAsync.UserToken as ASyncToken;
                if (tmp != null)
                {
                    tmp.Disconnect(message);
                }
            }

            socketAsync.UserToken = null;
#if !COREFX
            socketAsync.AcceptSocket.Close();
#endif
            socketAsync.AcceptSocket.Dispose();
            LogAction.Log(message);
        }
Example #7
0
 public AsyncCalls(ASyncToken token, Fiber fiber)
 {
     this.AsyncUser = token;
     this.fiber     = fiber;
 }
Example #8
0
        /// <summary>
        /// 创建注册 ASyncToken
        /// </summary>
        /// <param name="socketAsync"></param>
        /// <returns></returns>
        private ASyncToken NewASyncToken(SocketAsyncEventArgs socketAsync)
        {
            ASyncToken tmp = new ASyncToken(socketAsync, this, MaxBuffsize);

            return(tmp);
        }