C# 클래스 WDServer.Server

파일 보기 프로젝트 열기: Good4m/WindowsDefender 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
CLIENT_TIMEOUT int
DEBUG bool
RUNNING bool
_matches Match>.ConcurrentDictionary
_users User>.ConcurrentDictionary

공개 메소드들

메소드 설명
OnJoin ( IPEndPoint remoteEndPoint, string ipAddress, Instruction instruction ) : void

When the JOIN command is received by a user.

Server ( ) : System

Entry point. It creates a new thread that will be checking for timeouts. Listens on the main thread, for any instructions from the client.

비공개 메소드들

메소드 설명
AddToMatch ( User user ) : void

Adds a user to his/her Match. If it doesn't exist yet then it will be created.

Init ( ) : void

Initializes the server socket and tells the user if everything worked.

Listen ( ) : void

Listens for packets and responds accordingly by passing the incoming data to other functions.

OnCommand ( string ipAddress, Instruction instruction, byte data ) : void

When a command instruction is received it is simply echoed to everyone in the same match as the user.

OnDisconnect ( string ipAddress ) : void

Disconnects a user based on their IP address.

ResetUserTimeout ( string ipAddress ) : void

Resets a user's timeout (heartbeat counter).

SendToMatch ( User user, byte data ) : void

Sends data to all users in a match. The data is from one client and it needs to find the match that that one client belongs to, but will broadcast to all client in the match.

TimeoutCheckerThread ( ) : void

If we haven't received messages from users for awhile, we consider them disconnected and they can be removed from any match they were a part of.

메소드 상세

OnJoin() 공개 메소드

When the JOIN command is received by a user.
public OnJoin ( IPEndPoint remoteEndPoint, string ipAddress, Instruction instruction ) : void
remoteEndPoint System.Net.IPEndPoint The information such as IP, port and etc. of the client that just sent the 'Join' Instruction.
ipAddress string The ip address of the client that requested to join.
instruction Instruction The Instruction that the client sent.
리턴 void

Server() 공개 메소드

Entry point. It creates a new thread that will be checking for timeouts. Listens on the main thread, for any instructions from the client.
public Server ( ) : System
리턴 System

프로퍼티 상세

CLIENT_TIMEOUT 공개적으로 정적으로 프로퍼티

The amount of seconds that the server waits before kicking the client out.
public static int CLIENT_TIMEOUT
리턴 int

DEBUG 공개적으로 정적으로 프로퍼티

Set this to false for Release builds so we aren't wasting cycles by printing to the console.
public static bool DEBUG
리턴 bool

RUNNING 공개적으로 정적으로 프로퍼티

If this is set to false, the server will stop listening and exit.
public static bool RUNNING
리턴 bool

_matches 공개적으로 프로퍼티

A list of the matches that are currently in session.
public ConcurrentDictionary _matches
리턴 Match>.ConcurrentDictionary

_users 공개적으로 프로퍼티

A list of the users that are currently connected to the server with IP addresses of the users being the key.
public ConcurrentDictionary _users
리턴 User>.ConcurrentDictionary