public OSClient(IEFMagLinkRepository repository) { // First we set up our mutex and semaphore mutex = new Mutex(); connected = false; _repository = repository; item = new SocketAsyncEventArgs(); _timerClient.Elapsed += new System.Timers.ElapsedEventHandler(_timerClient_Elapsed); _timerClient.Interval = 10000; _timerClient.Start(); _timerClientConnecTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerClientConnecTimer_Elapsed); _timerClientConnecTimer.Interval = 15000; _timerClientConnecTimer.Start(); numconnections = 0; item.Completed += new EventHandler<SocketAsyncEventArgs>(OnIOCompleted); item.SetBuffer(new Byte[Convert.ToInt32(Settings._instance.BufferSize)], 0, Convert.ToInt32(Settings._instance.BufferSize)); socketpool = new OSAsyncEventStack(Convert.ToInt32(Settings._instance.NumConnect)); for (Int32 i = 0; i < Convert.ToInt32(Settings._instance.NumConnect); i++) { SocketAsyncEventArgs item1 = new SocketAsyncEventArgs(); item1.Completed += new EventHandler<SocketAsyncEventArgs>(OnIOCompleted); item1.SetBuffer(new Byte[Convert.ToInt32(Settings._instance.BufferSize)], 0, Convert.ToInt32(Settings._instance.BufferSize)); socketpool.Push(item1); } }
// The read socket that creates this object sends a copy of its "parent" accept socket in as a reference // We also take in a max buffer size for the data to be read off of the read socket public OSUserToken(Socket readSocket, Int32 bufferSize, IEFMagLinkRepository repository) { _repository = repository; ownersocket = readSocket; stringbuilder = new StringBuilder(bufferSize); }
// Default constructor public OSServer(IEFMagLinkRepository repository) { _repository = repository; exceptionthrown = false; // First we set up our mutex and semaphore mutex = new Mutex(); numconnections = 0; // Then we create our stack of read sockets socketpool = new OSAsyncEventStack(Convert.ToInt32(Settings._instance.NumConnect)); // Now we create enough read sockets to service the maximum number of clients // that we will allow on the server // We also assign the event handler for IO Completed to each socket as we create it // and set up its buffer to the right size. // Then we push it onto our stack to wait for a client connection for (Int32 i = 0; i < Convert.ToInt32(Settings._instance.NumConnect); i++) { SocketAsyncEventArgs item = new SocketAsyncEventArgs(); item.Completed += new EventHandler<SocketAsyncEventArgs>(OnIOCompleted); item.SetBuffer(new Byte[Convert.ToInt32(Settings._instance.BufferSize)], 0, Convert.ToInt32(Settings._instance.BufferSize)); socketpool.Push(item); } }
public AckMessages(String message , IEFMagLinkRepository repository) { _repository = repository; this.ack = this.makeAck(message); }