Cakewalk.NetEntity.NetEntity C# (CSharp) Метод

NetEntity() публичный Метод

Create a new entity from a socket and immediately assign it a world id. Requires async socket context objects with buffers pre-assigned
public NetEntity ( Socket socket, int worldID, SocketAsyncEventArgs sendEventArgs, SocketAsyncEventArgs receiveEventArgs ) : System
socket System.Net.Sockets.Socket
worldID int
sendEventArgs System.Net.Sockets.SocketAsyncEventArgs
receiveEventArgs System.Net.Sockets.SocketAsyncEventArgs
Результат System
        public NetEntity(Socket socket, int worldID, SocketAsyncEventArgs sendEventArgs, SocketAsyncEventArgs receiveEventArgs)
        {
            WorldID = worldID;

            m_sendArgs = sendEventArgs;
            m_sendArgs.Completed += SendCompleted;
            m_receiveArgs = receiveEventArgs;
            m_receiveArgs.Completed += ReceiveCompleted;

            unsafe
            {
                //Get the pointer for the send buffer
                byte[] buffer = m_sendArgs.Buffer;
                fixed (byte* bufPtr = buffer)
                {
                    m_sendBufferPtr = (IntPtr)(bufPtr + m_sendArgs.Offset);
                }
            }

            //Setup socket
            m_socket = socket;
            socket.NoDelay = true; //No nagling
            socket.ReceiveBufferSize = BUFFER_SIZE;
            socket.SendBufferSize = BUFFER_SIZE;

            AuthState = EntityAuthState.Unauthorised;

            //Pin buffers so that we can block copy structs to / from them
            m_workingPacketBufferHandle = GCHandle.Alloc(m_workingPacketBuffer, GCHandleType.Pinned);

            m_ioStopToken = new CancellationTokenSource();

            //Kick off net IO tasks
            //QueueSend();
            QueueReceive();
        }