C# Класс BF2Statistics.Gamespy.Net.GamespyTcpSocket

This class represents a high performance Async Tcp Socket wrapper that is used to act as a base for all Gamespy protocol Tcp connections.
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
BufferManager BF2Statistics.Net.BufferManager
BufferSizePerEventArg int
ConcurrentAcceptPoolSize int
ConnectionEnforceMode EnforceMode
FullErrorMessage string
Listener Socket
MaxConnectionsEnforcer System.Threading.SemaphoreSlim
MaxNumConnections int
SocketAcceptPool BF2Statistics.Net.SocketAsyncEventArgsPool
SocketReadWritePool BF2Statistics.Net.SocketAsyncEventArgsPool
WaitTimeout int

Открытые методы

Метод Описание
Dispose ( ) : void

Releases all Objects held by this socket. Will also shutdown the socket if its still running

GamespyTcpSocket ( int Port, int MaxConnections ) : System

Creates a new TCP socket for handling Gamespy Protocol

Release ( GamespyTcpStream Stream ) : void

Releases the Stream's SocketAsyncEventArgs back to the pool, and free's up another slot for a new client to connect

Защищенные методы

Метод Описание
PrepareAccept ( SocketAsyncEventArgs AcceptEventArg ) : void

Once a connection has been received, its handed off here to convert it into our client object, and prepared to be handed off to the parent for processing

ProcessAccept ( GamespyTcpStream Stream ) : void

When a new connection is established, the parent class is responsible for processing the connected client

ShutdownSocket ( ) : void

When called, this method will stop accepting new clients, and stop all I/O ops on all connections. Dispose still needs to be called afterwards!

StartAcceptAsync ( ) : void

Begins accepting a new Connection asynchronously

Описание методов

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

Releases all Objects held by this socket. Will also shutdown the socket if its still running
public Dispose ( ) : void
Результат void

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

Creates a new TCP socket for handling Gamespy Protocol
public GamespyTcpSocket ( int Port, int MaxConnections ) : System
Port int The port this socket will be bound to
MaxConnections int The maximum number of concurrent connections
Результат System

PrepareAccept() защищенный Метод

Once a connection has been received, its handed off here to convert it into our client object, and prepared to be handed off to the parent for processing
protected PrepareAccept ( SocketAsyncEventArgs AcceptEventArg ) : void
AcceptEventArg System.Net.Sockets.SocketAsyncEventArgs
Результат void

ProcessAccept() защищенный абстрактный Метод

When a new connection is established, the parent class is responsible for processing the connected client
protected abstract ProcessAccept ( GamespyTcpStream Stream ) : void
Stream GamespyTcpStream A GamespyTcpStream object that wraps the I/O AsyncEventArgs and socket
Результат void

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

Releases the Stream's SocketAsyncEventArgs back to the pool, and free's up another slot for a new client to connect
public Release ( GamespyTcpStream Stream ) : void
Stream GamespyTcpStream The GamespyTcpStream object that is being released.
Результат void

ShutdownSocket() защищенный Метод

When called, this method will stop accepting new clients, and stop all I/O ops on all connections. Dispose still needs to be called afterwards!
protected ShutdownSocket ( ) : void
Результат void

StartAcceptAsync() защищенный Метод

Begins accepting a new Connection asynchronously
protected StartAcceptAsync ( ) : void
Результат void

Описание свойств

BufferManager защищенное свойство

Buffers for sockets are unmanaged by .NET, which means that memory will get fragmented because the GC can't touch these byte arrays. So we will manage our buffers manually
protected BufferManager,BF2Statistics.Net BufferManager
Результат BF2Statistics.Net.BufferManager

BufferSizePerEventArg защищенное свойство

The amount of bytes each SocketAysncEventArgs object will get assigned to in the buffer manager.
protected int BufferSizePerEventArg
Результат int

ConcurrentAcceptPoolSize защищенное свойство

The initial size of the concurrent accept pool when accepting new connections. High volume of connections will increase the pool size if need be 4 should be a pretty good init compacity since accepting a client is pretty fast
protected int ConcurrentAcceptPoolSize
Результат int

ConnectionEnforceMode защищенное свойство

Determines where the MaxConnectionsEnforcer stops to wait for a spot to open, and allow the connecting client through.
protected EnforceMode ConnectionEnforceMode
Результат EnforceMode

FullErrorMessage защищенное свойство

The error message to display if the server is full. Only works if ConnectionEnforceMode is set to DuringPrepare. If left empty, no message will be sent back to the client
protected string FullErrorMessage
Результат string

Listener защищенное свойство

Our Listening Socket
protected Socket Listener
Результат Socket

MaxConnectionsEnforcer защищенное свойство

Use a Semaphore to prevent more then the MaxNumConnections clients from logging in at once.
protected SemaphoreSlim,System.Threading MaxConnectionsEnforcer
Результат System.Threading.SemaphoreSlim

MaxNumConnections защищенное свойство

Max number of concurrent open and active connections. Increasing this number will also increase the IO Buffer by BufferSizePerEventArg * 2
protected int MaxNumConnections
Результат int

SocketAcceptPool защищенное свойство

A pool of reusable SocketAsyncEventArgs objects for accept operations
protected SocketAsyncEventArgsPool,BF2Statistics.Net SocketAcceptPool
Результат BF2Statistics.Net.SocketAsyncEventArgsPool

SocketReadWritePool защищенное свойство

A pool of reusable SocketAsyncEventArgs objects for receive and send socket operations
protected SocketAsyncEventArgsPool,BF2Statistics.Net SocketReadWritePool
Результат BF2Statistics.Net.SocketAsyncEventArgsPool

WaitTimeout защищенное свойство

If the ConnectionEnforceMode is set to DuringPrepare, then the wait timeout is set here
protected int WaitTimeout
Результат int