コード例 #1
0
 protected ASocket(Socket socket)
 {
     _textReceived           = "";
     _processingMessages     = new List <string>();
     _splitMessages          = new List <string>();
     _awaitingCommandsEvents = new Queue <ManualResetEvent>();
     _awaitingCommandReturns = new Dictionary <string, string>();
     _commandThreads         = new Dictionary <string, ManualResetEvent>();
     _awaitingCommandReturns = new Dictionary <string, string>();
     _eventProcessor         = new delProcessEventMessage(ProcessEvent);
     _handlers    = new List <sEventHandler>();
     _socket      = socket;
     _isConnected = _socket.Connected;
     if (!_isConnected)
     {
         throw new Exception("Unable to construct an instance of the abstract class ASocket using the contructor with a socket without passing a connected socket.");
     }
     _ipAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;
     _port      = ((IPEndPoint)_socket.RemoteEndPoint).Port;
     _preSocketReady();
     _mreMessageWaiting   = new ManualResetEvent(false);
     _backgroundProcessor = new Thread(new ThreadStart(_MessageProcessorStart));
     _backgroundProcessor.IsBackground = true;
     _backgroundProcessor.Start();
     _socket.ReceiveTimeout             = 1000;
     _backgroundDataReader              = new Thread(new ThreadStart(_SocketDataReaderStart));
     _backgroundDataReader.IsBackground = true;
     _backgroundDataReader.Start();
     this.RegisterEvent(BACKGROUND_API_RESPONSE_EVENT);
 }
コード例 #2
0
        protected ASocket(IPAddress ip, int port)
        {
            _textReceived           = "";
            _processingMessages     = new List <string>();
            _splitMessages          = new List <string>();
            _awaitingCommandsEvents = new Queue <ManualResetEvent>();
            _awaitingCommandReturns = new Dictionary <string, string>();
            _commandThreads         = new Dictionary <string, ManualResetEvent>();
            _awaitingCommandReturns = new Dictionary <string, string>();
            _eventProcessor         = new delProcessEventMessage(ProcessEvent);
            _handlers            = new List <sEventHandler>();
            _exit                = false;
            _isConnected         = false;
            _ipAddress           = ip;
            _port                = port;
            _awaitingCommands    = new Queue <byte[]>();
            _socket              = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _mreMessageWaiting   = new ManualResetEvent(false);
            _backgroundProcessor = new Thread(new ThreadStart(_MessageProcessorStart));
            _backgroundProcessor.Start();
            _socket.ReceiveTimeout = 1000;
            _preSocketReady();
            Thread th = new Thread(new ThreadStart(BackgroundRun));

            th.IsBackground = true;
            th.Start();
        }
コード例 #3
0
 protected ASocket(Socket socket)
 {
     _textReceived = "";
     _processingMessages = new List<string>();
     _splitMessages = new List<string>();
     _awaitingCommandsEvents = new Queue<ManualResetEvent>();
     _awaitingCommandReturns = new Dictionary<string, string>();
     _commandThreads = new Dictionary<string, ManualResetEvent>();
     _awaitingCommandReturns = new Dictionary<string, string>();
     _eventProcessor = new delProcessEventMessage(ProcessEvent);
     _handlers = new List<sEventHandler>();
     _socket = socket;
     _isConnected = _socket.Connected;
     if (!_isConnected)
         throw new Exception("Unable to construct an instance of the abstract class ASocket using the contructor with a socket without passing a connected socket.");
     _ipAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;
     _port = ((IPEndPoint)_socket.RemoteEndPoint).Port;
     _preSocketReady();
     _mreMessageWaiting = new ManualResetEvent(false);
     _backgroundProcessor = new Thread(new ThreadStart(_MessageProcessorStart));
     _backgroundProcessor.IsBackground = true;
     _backgroundProcessor.Start();
     _socket.ReceiveTimeout = 1000;
     _backgroundDataReader = new Thread(new ThreadStart(_SocketDataReaderStart));
     _backgroundDataReader.IsBackground = true;
     _backgroundDataReader.Start();
     this.RegisterEvent(BACKGROUND_API_RESPONSE_EVENT);
 }
コード例 #4
0
 public OutboundSocket(IPAddress ip, int port, string password, delProcessEventMessage eventDelegate, delProcessLogMessage logDelegate, delReloadXml preReloadCall, delReloadXml postReloadCall)
     : base(ip, port)
 {
     _eventDelegate  = eventDelegate;
     _logDelegate    = logDelegate;
     _preReloadCall  = preReloadCall;
     _postReloadCall = postReloadCall;
     _password       = password;
 }
コード例 #5
0
 public sEventHandler(string eventName, string uuid, string callerUUID, string channelName, delProcessEventMessage handler, long id)
 {
     _eventName   = eventName;
     _uuid        = uuid;
     _callerUUID  = callerUUID;
     _channelName = channelName;
     _handler     = handler;
     _id          = id;
 }
コード例 #6
0
 public OutboundSocket(IPAddress ip,int port,string password,delProcessEventMessage eventDelegate,delProcessLogMessage logDelegate,delReloadXml preReloadCall,delReloadXml postReloadCall)
     : base(ip,port)
 {
     _eventDelegate = eventDelegate;
     _logDelegate = logDelegate;
     _preReloadCall = preReloadCall;
     _postReloadCall = postReloadCall;
     _password = password;
 }
コード例 #7
0
        public long RegisterEventHandler(string eventName, string uuid, string callerUUID, string channelName, delProcessEventMessage handler)
        {
            long id = _random.NextLong();

            lock (_handlers)
            {
                _handlers.Add(new sEventHandler(eventName, uuid, callerUUID, channelName, handler, id));
            }
            return(id);
        }
コード例 #8
0
 protected ASocket(IPAddress ip, int port)
 {
     _textReceived = "";
     _processingMessages = new List<string>();
     _splitMessages = new List<string>();
     _awaitingCommandsEvents = new Queue<ManualResetEvent>();
     _awaitingCommandReturns = new Dictionary<string, string>();
     _commandThreads = new Dictionary<string, ManualResetEvent>();
     _awaitingCommandReturns = new Dictionary<string, string>();
     _eventProcessor = new delProcessEventMessage(ProcessEvent);
     _handlers = new List<sEventHandler>();
     _exit = false;
     _isConnected = false;
     _ipAddress = ip;
     _port = port;
     _awaitingCommands = new Queue<byte[]>();
     _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     _mreMessageWaiting = new ManualResetEvent(false);
     _backgroundProcessor = new Thread(new ThreadStart(_MessageProcessorStart));
     _backgroundProcessor.Start();
     _socket.ReceiveTimeout = 1000;
     _preSocketReady();
     Thread th = new Thread(new ThreadStart(BackgroundRun));
     th.IsBackground = true;
     th.Start();
 }
コード例 #9
0
 public sEventHandler(string eventName, string uuid,string callerUUID,string channelName, delProcessEventMessage handler,long id)
 {
     _eventName = eventName;
     _uuid = uuid;
     _callerUUID = callerUUID;
     _channelName = channelName;
     _handler = handler;
     _id = id;
 }
コード例 #10
0
 public long RegisterEventHandler(string eventName, string uuid, string callerUUID, string channelName, delProcessEventMessage handler)
 {
     long id = _random.NextLong();
     lock (_handlers)
     {
         _handlers.Add(new sEventHandler(eventName, uuid, callerUUID, channelName, handler, id));
     }
     return id;
 }