public PayLoad OnMessage(GingerSocket.eProtocolMessageType MessageType, object obj = null) { MessageEventHandler handler = Message; if (handler != null) { MessageEventArgs EVArgs = new MessageEventArgs(MessageType, obj); handler(this, EVArgs); if (IsGingerSocketLogging) { GingerSocketLog GSL = new GingerSocketLog(); GSL.TimeStamp = DateTime.Now; GSL.Name = MessageType.ToString(); GSL.Info = obj.ToString(); GSL.LogType = "Message"; GingerSocketLogs.Add(GSL); } return(EVArgs.Response); } else { return(null); } }
public virtual void Disconnect() { lock (mLock) { mMessageReceivedHandler = null; } }
public virtual void Disconnect() { lock (this._EventLock) { this._MessageReceived = null; } }
public static void Subscribe <T>(MessageEventHandler <T> messageEventHandler, string eventName = null) { var channelType = typeof(T); var channels = Subscriptions.Channels; Dictionary <string, object> channel = null; if (!channels.ContainsKey(channelType)) { channel = new Dictionary <string, object>(); channels.Add(channelType, channel); } else { channel = channels[channelType]; } if (channel != null) { eventName = eventName ?? string.Empty; if (!channel.ContainsKey(eventName)) { channel.Add(eventName, new List <MessageEventHandler <T> >()); } var subs = channel[eventName]; if (subs != null) { var subscribers = (List <MessageEventHandler <T> >)subs; subscribers.Add(messageEventHandler); } } }
public void IssueRequest(string requestName, Dictionary<string, string> parameters, MessageEventHandler callback) { Packet request = RecognizedPacket.CreatePacketFromFormattedData(requestName, parameters); request = RconProtocol.SendRequest(request); RequestCallbacks[request.SequenceNumber] = callback; RequestPackets[request.SequenceNumber] = request; }
/// <summary> Constructor for SocketServer Suppport </summary> /// <param name="socketServer"> A Reference to the parent SocketServer </param> /// <param name="clientSocket"> The Socket object we are encapsulating </param> /// <param name="socketListArray"> The index of the SocketServer Socket List Array </param> /// <param name="ipAddress"> The IpAddress of the remote server </param> /// <param name="port"> The Port of the remote server </param> /// <param name="messageHandler"> Reference to the user defined message handler function </param> /// <param name="closeHandler"> Reference to the user defined close handler function </param> /// <param name="errorHandler"> Reference to the user defined error handler function </param> /// <param name="sizeOfRawBuffer"> The size of the raw buffer </param> /// <param name="userArg"> A Reference to the Users arguments </param> public SocketClient(SocketServer socketServer, Socket clientSocket, string ipAddress, int port, int sizeOfRawBuffer, object userArg, MessageEventHandler messageHandler, CloseEventHandler closeHandler, ErrorEventHandler errorHandler) : this(sizeOfRawBuffer, userArg, messageHandler, closeHandler, errorHandler) { // Set reference to SocketServer this.socketServer = socketServer; // Init the socket references this.clientSocket = clientSocket; // Set the Ipaddress and Port this.ipAddress = ipAddress; this.port = port; // Init the NetworkStream reference this.networkStream = new NetworkStream(this.clientSocket); // Set these socket options this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.ReceiveBuffer, this.receiveBufferSize); this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.SendBuffer, this.sendBufferSize); this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.DontLinger, 1); this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Tcp, System.Net.Sockets.SocketOptionName.NoDelay, 1); // Wait for a message Receive(); }
// The external command invokes this on the end-user's request public void ShowForm(UIApplication uiapp) { uiapp.Application.WriteJournalComment("[STREAMVR] APP SHOW FORM", true); // If we do not have a dialog yet, create and show it if (_uiForm == null || !_uiForm.IsActive) { // A new handler to handle request posting by the dialog MessageEventHandler handler = new MessageEventHandler(); // External Event for the dialog to use (to post requests) ExternalEvent exEvent = ExternalEvent.CreateJournalable(handler); uiapp.Application.WriteJournalComment("[STREAMVR] CREATING FORM", true); var startingViews = new FilteredElementCollector(uiapp.ActiveUIDocument.Document). OfClass(typeof(View3D)). Select(e => e as View3D); _uiForm = new WPF.StreamVRUI(exEvent, handler, (string msg) => { uiapp.Application.WriteJournalComment(msg, true); }) { ServerURL = StreamVRApp.Instance.BaseServerURL, UserName = uiapp.Application.Username, RoomCode = "123456", StartingView = startingViews.FirstOrDefault()?.Name ?? "", StartingViewOptions = startingViews.Select(v => v.Name) }; _uiForm.InitialLoad(); _uiForm.Show(); } }
public static void Main() { //init instances: LogControl logControl = new LogControl(); SystemControl sysControl = new SystemControl(logControl); ReplayManager replayManager = new ReplayManager(); SessionIdHandler sidHandler = new SessionIdHandler(); GameCenter gameCenter = new GameCenter(sysControl, logControl, replayManager, sidHandler); var commHandler = CommunicationHandler.GetInstance(); MessageEventHandler eventHandler = new MessageEventHandler(gameCenter, sysControl, logControl, replayManager, sidHandler); gameCenter.SetMessageHandler(eventHandler); var webEventHandler = new WebEventHandler(new ServerEventHandler(sidHandler, null, gameCenter, sysControl, logControl, replayManager, null)); WebCommHandler webCommHandler = new WebCommHandler(webEventHandler); Task commTask = Task.Factory.StartNew(commHandler.Start); Task webCommTask = Task.Factory.StartNew(webCommHandler.Start); Console.WriteLine("starting comm"); Task eventTask = Task.Factory.StartNew(eventHandler.HandleIncomingMsgs); commTask.Wait(); webCommTask.Wait(); }
/// <summary> /// Function to start the SocketServer /// </summary> /// <param name="ipAddress"> The IpAddress to listening on </param> /// <param name="port"> The Port to listen on </param> /// <param name="sizeOfRawBuffer"> Size of the Raw Buffer </param> /// <param name="userArg"> User supplied arguments </param> /// <param name="messageHandler"> Function pointer to the user MessageHandler function </param> /// <param name="acceptHandler"> Function pointer to the user AcceptHandler function </param> /// <param name="closeHandler"> Function pointer to the user CloseHandler function </param> /// <param name="errorHandler"> Function pointer to the user ErrorHandler function </param> public void Start(string ipAddress, int port, int sizeOfRawBuffer, object userArg, MessageEventHandler messageHandler, AcceptEventHandler acceptHandler, CloseEventHandler closeHandler, ErrorEventHandler errorHandler) { // Is an AcceptThread currently running if (this.acceptThread == null) { // Set connection values this.IpAddress = ipAddress; this.Port = port; // Save the Handler Functions this.messageHandler = messageHandler; this.acceptHandler = acceptHandler; this.closeHandler = closeHandler; this.errorHandler = errorHandler; // Save the buffer size and user arguments this.SizeOfRawBuffer = sizeOfRawBuffer; this.UserArg = userArg; // Create a new TCPListner and start it up var endpoint = GetIPEndPoint(this.ipAddress, this.port); this.tcpListener = new TcpListener(endpoint); this.tcpListener.Start(maxAccept); // Start the listening thread if one is currently not running ThreadStart tsThread = new ThreadStart(AcceptThread); this.acceptThread = new Thread(tsThread); this.acceptThread.Name = "Notification.Accept"; this.acceptThread.Start(); } }
public virtual void Disconnect() { lock (_EventLock) { _MessageReceived = null; } }
public void AddMessage(string message, int seconds) { Thread.Sleep(1000 * seconds); var thread = Thread.CurrentThread.ManagedThreadId; MessageEventHandler?.Invoke(this, new TaskMessageEventArgs($"{message} Hilo actual evento: {thread}\n")); }
public MessageProcessor(MessageQueue queue, MessageEventHandler messageHandler, ErrorHandler errorHandler) { this.messageQueue = queue; this.messageHandler = messageHandler; this.errorHandler = errorHandler; }
private void InitializeEventHandlers() { agentEventHandler = new AgentEventHandler(logger, this, tenantIOService); tenantEventHandler = new TenantEventHandler(logger, this, tenantIOService); producerEventHandler = new ProducerEventHandler(logger, this, producerIOService); consumerEventHandler = new ConsumerEventHandler(logger, this, consumerIOService, messageIOService); messageEventHandler = new MessageEventHandler(logger, this, messageIOService); }
public void RemoveMessageListener(short packetId, MessageEventHandler handler) { // TODO: 如果允许重复监听, 这里需做相应修改 if (m_Handlers.ContainsKey(packetId)) { m_Handlers.Remove(packetId); } }
public MessageProcessor(MessageQueue queue, MessageEventHandler messageHandler, ErrorHandler errorHandler) { this.messageQueue = queue; this.messageHandler = messageHandler; this.errorHandler = errorHandler; }
public void OnOutPutMessageReceived(MessageEventArgs e) { MessageEventHandler handler = OutPutMessageReceived; if (handler != null) { handler(this, e); } }
protected virtual void OnMessage(MessageEventArgs message) { MessageEventHandler handler = Message; if (handler != null) { handler(this, message); } }
/// <summary> /// Instantiates a new HeatCore. /// </summary> /// <param name="messageHandler">The message handler for the core.</param> internal HeatCore(MessageEventHandler messageHandler) { this.MessageHandler = messageHandler; this.harvester = new Harvester(); this.harvester.Message += messageHandler; this.mutator = new Mutator(); this.mutator.Message += messageHandler; }
public virtual void fireReportError(string s) { MessageEventHandler eventDelegate = (MessageEventHandler)((CharScanner)source).Events[Parser.ReportErrorEventKey]; if (eventDelegate != null) { messageEvent.setValues(MessageEventArgs.ERROR, s); eventDelegate(source, messageEvent); } checkController(); }
public virtual void fireReportWarning(string s) { MessageEventHandler eventDelegate = (MessageEventHandler)((Parser)source).Events[Parser.ReportWarningEventKey]; if (eventDelegate != null) { messageEvent.setValues(MessageEventArgs.WARNING, s); eventDelegate(source, messageEvent); } checkController(); }
public virtual void fireReportError(System.Exception e) { MessageEventHandler eventDelegate = (MessageEventHandler)((Parser)source).Events[Parser.ReportErrorEventKey]; if (eventDelegate != null) { messageEvent.setValues(MessageEventArgs.ERROR, e.ToString()); eventDelegate(source, messageEvent); } checkController(); }
public static void RegisterMessageEventService(string command, MessageEventHandler handler) { if (MessageEventHandlers.ContainsKey(command)) { MessageEventHandlers[command] += handler; } else { MessageEventHandlers.Add(command, handler); } }
/// <summary> /// Instantiate a new PreprocessorCore. /// </summary> /// <param name="extensionsByPrefix">The extensions indexed by their prefixes.</param> /// <param name="messageHandler">The message handler.</param> /// <param name="sourceFile">The source file being preprocessed.</param> /// <param name="variables">The variables defined prior to preprocessing.</param> internal PreprocessorCore(Hashtable extensionsByPrefix, MessageEventHandler messageHandler, string sourceFile, IDictionary <string, string> variables) { this.extensionsByPrefix = extensionsByPrefix; this.MessageHandler = messageHandler; this.sourceFile = String.IsNullOrEmpty(sourceFile) ? null : Path.GetFullPath(sourceFile); this.variables = new Dictionary <string, string>(); foreach (var entry in variables) { this.AddVariable(null, entry.Key, entry.Value); } }
/// <summary> /// Instantiate a new PreprocessorCore. /// </summary> /// <param name="extensionsByPrefix">The extensions indexed by their prefixes.</param> /// <param name="messageHandler">The message handler.</param> /// <param name="sourceFile">The source file being preprocessed.</param> /// <param name="variables">The variables defined prior to preprocessing.</param> internal PreprocessorCore(Hashtable extensionsByPrefix, MessageEventHandler messageHandler, string sourceFile, Hashtable variables) { this.extensionsByPrefix = extensionsByPrefix; this.MessageHandler = messageHandler; this.sourceFile = Path.GetFullPath(sourceFile); this.variables = new Hashtable(); foreach (DictionaryEntry entry in variables) { this.AddVariable(null, (string)entry.Key, (string)entry.Value); } }
/// <summary> /// Instantiate a new PreprocessorCore. /// </summary> /// <param name="extensionsByPrefix">The extensions indexed by their prefixes.</param> /// <param name="messageHandler">The message handler.</param> /// <param name="sourceFile">The source file being preprocessed.</param> /// <param name="variables">The variables defined prior to preprocessing.</param> internal PreprocessorCore(Hashtable extensionsByPrefix, MessageEventHandler messageHandler, string sourceFile, Hashtable variables) { this.extensionsByPrefix = extensionsByPrefix; this.MessageHandler = messageHandler; this.sourceFile = Path.GetFullPath(sourceFile); this.variables = new Hashtable(); foreach (DictionaryEntry entry in variables) { this.AddVariable(null, (string)entry.Key, (string)entry.Value); } }
/// <summary> /// Handle new connections /// </summary> /// <param name="connection">New connection</param> protected override void OnConnection(InputConnection connection) { // TODO: Save active connection list // Set new connection handler if (this._newConnectionEventHandler == null) { this._newConnectionEventHandler = new MessageEventHandler(NewConnectionHandler); } connection.OnMessage += this._newConnectionEventHandler; }
/// <summary> /// Overloaded constructor for client support /// </summary> /// <param name="sendBufferSize"></param> /// <param name="receiveBufferSize"></param> /// <param name="sizeOfRawBuffer"> The size of the raw buffer </param> /// <param name="userArg"> A Reference to the Users arguments </param> /// <param name="messageHandler"> Reference to the user defined message handler method </param> /// <param name="closeHandler"> Reference to the user defined close handler method </param> /// <param name="errorHandler"> Reference to the user defined error handler method </param> public SocketClient(int sendBufferSize, int receiveBufferSize, int sizeOfRawBuffer, object userArg, MessageEventHandler messageHandler, CloseEventHandler closeHandler, ErrorEventHandler errorHandler ) : this(sizeOfRawBuffer, userArg, messageHandler, closeHandler, errorHandler) { //Set the size of the send/receive buffers this.sendBufferSize = sendBufferSize; this.receiveBufferSize = receiveBufferSize; }
public void AddMessageListener(short packetId, MessageEventHandler handler) { if (m_Handlers.ContainsKey(packetId)) { // TODO: 客户端是否会存在两个地方都需要监听同一个消息的地方 // TODO: 可以通过Delete.MethodInfo来判定是否是重复监听 // m_Handlers[packetId] += handler; throw new MessageDuplicatedListenException(packetId); } else { m_Handlers[packetId] = handler; } }
private void Bootstrapper_StatusChanged(object sender, MessageEventArgs e) { if (statusLbl.InvokeRequired) { var inThread = new MessageEventHandler(Bootstrapper_StatusChanged); statusLbl.Invoke(inThread, sender, e); } else { statusLbl.Text = e.Message; statusLbl.Refresh(); BringToFront(); } }
public PrepareNoteForm(NetworkNode client, string dbConnectionString, Log log) { this.client = client; this.dbConnectionString = dbConnectionString; this.log = log; InitializeComponent(); this.updateServerDelegate = new VoidDelegate(UpdateCurrentServerDetails); this.receiveHandler = new MessageEventHandler(client_MessageReceived); this.toggleSendButtonDelegate = new ButtonStringBoolDelegate(ToggleButton); this.closeDelegate = new DialogResultDelegeate(DoClose); this.timeDelegate = new VoidDelegate(UpdateTime); this.clockCallback = new System.Threading.TimerCallback(ClockTimerTimedout); }
private static void EndAsync(IAsyncResult ar) { MessageEventHandler d = null; try { var asres = (AsyncResult)ar; d = (MessageEventHandler)asres.AsyncDelegate; d.EndInvoke(ar); } catch { MessageEvent -= d; } }
private void SubthreadMessageReceive(MessageEventArgs e) { try { if (this.IsHandleCreated && !this.IsDisposed) { MessageEventHandler handler = new MessageEventHandler(MessageManage); this.Invoke(handler, new object[] { e }); } } catch (Exception) { //throw new Exception("", ex); } }
public StreamVRUI(ExternalEvent exEvent, MessageEventHandler handler, Action <string> debug) { _log = debug; InitializeComponent(); _exEvent = exEvent; _handler = handler; var assembly = Assembly.GetCallingAssembly(); var assemblyDir = new FileInfo(assembly.Location).Directory.FullName; var assemblyName = $"{assemblyDir}\\StreamVRLogo.png"; var uri = new Uri(assemblyName); var bitmap = new BitmapImage(uri); StreamVRIcon.Source = bitmap; }
static void Main(string[] args) { IEventHandler client1 = new MessageEventHandler(IPAddress.Parse("192.168.0.108"), 123); IEventHandler client2 = new MessageEventHandler(IPAddress.Parse("234.234.234.234"), 123); IEventHandler client3 = new MessageEventHandler(IPAddress.Parse("345.345.345.345"), 123); ISynchronousEventDemultiplexer synchronousEventDemultiplexer = new SynchronousEventDemultiplexer(); Reactor dispatcher = new Reactor(synchronousEventDemultiplexer); dispatcher.RegisterHandle(client1); dispatcher.RegisterHandle(client2); dispatcher.RegisterHandle(client3); dispatcher.HandleEvents(); }
private void Bootstrapper_EchoFeed(object sender, MessageEventArgs e) { if (log.InvokeRequired) { var inThread = new MessageEventHandler(Bootstrapper_EchoFeed); log.Invoke(inThread, sender, e); } else { if (!string.IsNullOrEmpty(log.Text)) { log.AppendText("\n"); } log.AppendText(e.Message); } }
/// <summary> /// Constructor for client support /// </summary> /// <param name="sizeOfRawBuffer"> The size of the raw buffer </param> /// <param name="userArg"> A Reference to the Users arguments </param> /// <param name="messageHandler"> Reference to the user defined message handler method </param> /// <param name="closeHandler"> Reference to the user defined close handler method </param> /// <param name="errorHandler"> Reference to the user defined error handler method </param> public SocketClient(int sizeOfRawBuffer, object userArg, MessageEventHandler messageHandler, CloseEventHandler closeHandler, ErrorEventHandler errorHandler) { // Create the raw buffer this.SizeOfRawBuffer = sizeOfRawBuffer; this.RawBuffer = new Byte[this.SizeOfRawBuffer]; // Save the user argument this.userArg = userArg; // Set the handler methods this.messageHandler = messageHandler; this.closeHandler = closeHandler; this.errorHandler = errorHandler; // Set the async socket method handlers this.callbackReadMethod = new AsyncCallback(ReceiveComplete); this.callbackWriteMethod = new AsyncCallback(SendComplete); this.m_Connected = true; // Init the dispose flag this.disposed = false; }
/// <summary> Constructor for SocketServer Suppport </summary> /// <param name="socketServer"> A Reference to the parent SocketServer </param> /// <param name="clientSocket"> The Socket object we are encapsulating </param> /// <param name="socketListArray"> The index of the SocketServer Socket List Array </param> /// <param name="ipAddress"> The IpAddress of the remote server </param> /// <param name="port"> The Port of the remote server </param> /// <param name="messageHandler"> Reference to the user defined message handler function </param> /// <param name="closeHandler"> Reference to the user defined close handler function </param> /// <param name="errorHandler"> Reference to the user defined error handler function </param> /// <param name="sizeOfRawBuffer"> The size of the raw buffer </param> /// <param name="userArg"> A Reference to the Users arguments </param> public SocketClient(SocketServer socketServer, Socket clientSocket, string ipAddress, int port, int sizeOfRawBuffer, object userArg, MessageEventHandler messageHandler, CloseEventHandler closeHandler, ErrorEventHandler errorHandler) : this(sizeOfRawBuffer, userArg, messageHandler, closeHandler, errorHandler) { // Set reference to SocketServer this.socketServer = socketServer; // Init the socket references this.clientSocket = clientSocket; // Set the Ipaddress and Port this.ipAddress = ipAddress; this.port = port; // Init the NetworkStream reference this.networkStream = new NetworkStream(this.clientSocket); // Set these socket options this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.ReceiveBuffer, this.receiveBufferSize); this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.SendBuffer, this.sendBufferSize); this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.DontLinger, 1); this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Tcp, System.Net.Sockets.SocketOptionName.NoDelay, 1); // Wait for a message Receive(); }
/// <summary> /// Overloaded constructor for client support /// </summary> /// <param name="sendBufferSize"></param> /// <param name="receiveBufferSize"></param> /// <param name="sizeOfRawBuffer"> The size of the raw buffer </param> /// <param name="userArg"> A Reference to the Users arguments </param> /// <param name="messageHandler"> Reference to the user defined message handler method </param> /// <param name="closeHandler"> Reference to the user defined close handler method </param> /// <param name="errorHandler"> Reference to the user defined error handler method </param> public SocketClient(int sendBufferSize, int receiveBufferSize, int sizeOfRawBuffer, object userArg, MessageEventHandler messageHandler, CloseEventHandler closeHandler, ErrorEventHandler errorHandler ) : this(sizeOfRawBuffer, userArg, messageHandler, closeHandler, errorHandler) { //Set the size of the send/receive buffers this.sendBufferSize = sendBufferSize; this.receiveBufferSize = receiveBufferSize; }
/** * Sets the instance to notify for incoming message events. * @param evtHandler the entity that will handle incoming messages. */ public virtual void SetEventHandler(MessageEventHandler evtHandler) { messageEventHandler = evtHandler; }
/// <summary> /// 初始化Peer /// </summary> /// <param name="socket">连接的Socket</param> /// <param name="onMessage">对onMessage事件的初始化</param> public Peer(Socket socket, MessageEventHandler onMessage) : this(socket) { this.onMessage += onMessage; }
public WebSocket( string url, EventHandler onOpen, MessageEventHandler onMessage, MessageEventHandler onError, EventHandler onClose) : this(url, String.Empty, onOpen, onMessage, onError, onClose) { }
public void Leave(string id) { Broadcast -= new MessageEventHandler(RaiseBroadcastEvent); Console.WriteLine(DateTime.Now + " : " + id + " has disconnected."); }
/// <summary> /// Instantiate a new melter core. /// </summary> /// <param name="messageHandler">The message handler.</param> public MelterCore(MessageEventHandler messageHandler) { this.MessageHandler = messageHandler; }
/// <summary> /// Constructor for decompiler core. /// </summary> /// <param name="writer">XmlTextWriter for writing generated source.</param> /// <param name="messageHandler">Message handler for generating messages.</param> internal DecompilerCore(XmlTextWriter writer, MessageEventHandler messageHandler) { this.writer = writer; this.MessageHandler = messageHandler; this.coveredTables = new Hashtable(); }
/// <summary> /// Scan the input files for unit tests and, if specified, generate a test package source file. /// </summary> /// <param name="extensions">The WiX extensions used by the input files.</param> /// <param name="inputFiles">The WiX object and library files to scan for unit tests.</param> /// <param name="outputFile">The optional generated test package source file.</param> /// <param name="message">Message handler.</param> /// <returns> /// If successful, the subset of InputFiles that are fragments (i.e., are not entry sections like Product) and should be included in a test package. /// If there were no unit tests in the input files or a test package couldn't be created, an empty enumerable. /// </returns> public static IEnumerable<string> Generate(StringCollection extensions, List<string> inputFiles, string outputFile, MessageEventHandler message) { Generator generator = new Generator(); generator.Extensions = extensions; generator.InputFiles = inputFiles; generator.OutputFile = outputFile; generator.Message += message; bool success = generator.Generate(); return success ? generator.InputFragments : Enumerable.Empty<string>(); }
/// <summary> /// Instantiates a new FabricatorCore. /// </summary> /// <param name="messageHandler">The message handler for the core.</param> public FabricatorCore(MessageEventHandler messageHandler) { this.Message = messageHandler; }
/// <summary> /// Function to start the SocketServer /// </summary> /// <param name="ipAddress"> The IpAddress to listening on </param> /// <param name="port"> The Port to listen on </param> /// <param name="sizeOfRawBuffer"> Size of the Raw Buffer </param> /// <param name="userArg"> User supplied arguments </param> /// <param name="messageHandler"> Function pointer to the user MessageHandler function </param> /// <param name="acceptHandler"> Function pointer to the user AcceptHandler function </param> /// <param name="closeHandler"> Function pointer to the user CloseHandler function </param> /// <param name="errorHandler"> Function pointer to the user ErrorHandler function </param> public void Start(string ipAddress, int port, int sizeOfRawBuffer, object userArg, MessageEventHandler messageHandler, AcceptEventHandler acceptHandler, CloseEventHandler closeHandler, ErrorEventHandler errorHandler) { // Is an AcceptThread currently running if (this.acceptThread == null) { // Set connection values this.IpAddress = ipAddress; this.Port = port; // Save the Handler Functions this.messageHandler = messageHandler; this.acceptHandler = acceptHandler; this.closeHandler = closeHandler; this.errorHandler = errorHandler; // Save the buffer size and user arguments this.SizeOfRawBuffer = sizeOfRawBuffer; this.UserArg = userArg; // Create a new TCPListner and start it up var endpoint = GetIPEndPoint(this.ipAddress, this.port); this.tcpListener = new TcpListener(endpoint); this.tcpListener.Start(maxAccept); // Start the listening thread if one is currently not running ThreadStart tsThread = new ThreadStart(AcceptThread); this.acceptThread = new Thread(tsThread); this.acceptThread.Name = "Notification.Accept"; this.acceptThread.Start(); } }
/// <summary> /// Scan the input files for unit tests and, if specified, generate a test package source file. /// </summary> /// <param name="extensions">The WiX extensions used by the input files.</param> /// <param name="inputFiles">The WiX object and library files to scan for unit tests.</param> /// <param name="outputFile">The optional generated test package source file.</param> /// <param name="message">Message handler.</param> /// <param name="inputFragments">The subset of InputFiles that are fragments (i.e., are not entry sections like Product) and should be included in a test package.</param> /// <returns>True if successful or False if there were no unit tests in the input files or a test package couldn't be created.</returns> public static bool Generate(StringCollection extensions, List<string> inputFiles, string outputFile, MessageEventHandler message, out List<string> inputFragments) { Generator generator = new Generator(); generator.Extensions = extensions; generator.InputFiles = inputFiles; generator.OutputFile = outputFile; generator.Message += message; bool success = generator.Generate(); inputFragments = generator.InputFragments; return success; }
/// <summary> /// Instantiate a new HarvesterCore. /// </summary> /// <param name="messageHandler">The message handler.</param> public HarvesterCore(MessageEventHandler messageHandler) { this.MessageHandler = messageHandler; }
public WebSocket( string url, string protocol, EventHandler onOpen, MessageEventHandler onMessage, MessageEventHandler onError, EventHandler onClose) : this(url, protocol) { this.OnOpen += onOpen; this.OnMessage += onMessage; this.OnError += onError; this.OnClose += onClose; Connect(); }
//--------------------------------------------------------------------- // Message-related functions //--------------------------------------------------------------------- public void RegisterHandler(string type, MessageEventHandler handler) { DebugUtils.DebugLog("New handler for message type '{0}'", type); message_handlers_[type] = handler; }
/// <summary> /// Adds an event handler. /// </summary> /// <param name="newHandler">The event handler to add.</param> public override void AddMessageEventHandler(MessageEventHandler newHandler) { base.AddMessageEventHandler(newHandler); validator.Extension.Message += newHandler; }
public void RegisterHandlerWithProtocol(string type, TransportProtocol protocol, MessageEventHandler handler) { if (protocol == TransportProtocol.kDefault) { RegisterHandler(type, handler); return; } DebugUtils.DebugLog("New handler for and message type '{0}' of '{1}' protocol.", type, protocol); message_protocols_[type] = protocol; message_handlers_[type] = handler; }
/// <summary> /// Instantiate a new decompiler core. /// </summary> /// <param name="rootElement">The root element of the decompiled database.</param> /// <param name="messageHandler">The message handler.</param> internal DecompilerCore(IParentElement rootElement, MessageEventHandler messageHandler) { this.elements = new Hashtable(); this.MessageHandler = messageHandler; this.rootElement = rootElement; }
public void Join(string id) { _callbackInstance = OperationContext.Current.GetCallbackChannel<IMyCallback>(); Broadcast += new MessageEventHandler(RaiseBroadcastEvent); Console.WriteLine(DateTime.Now + " : " + id + " has connected."); }
/// <summary> /// Instantiates a new HeatCore. /// </summary> /// <param name="messageHandler">The message handler for the core.</param> public HeatCore(MessageEventHandler messageHandler) { this.MessageHandler = messageHandler; this.harvester = new Harvester(); this.mutator = new Mutator(); }
protected virtual SocketClient AcceptedSocketClient(SocketServer socketServer, Socket clientSocket, string ipAddress, int port, int sizeOfRawBuffer, object userArg, MessageEventHandler messageHandler, CloseEventHandler closeHandler, ErrorEventHandler errorHandler) { return new SocketClient(socketServer, clientSocket, ipAddress, port, sizeOfRawBuffer, userArg, messageHandler, closeHandler, errorHandler); }
private void SetUpWorkings() { closeDelegate = new VoidDelegate(this.Close); connectionHandler = new DeviceNotification(DeviceManagement_NetworkConnected); InitialiseWiFi(); log.Name = "log"; log.LogMessage += new LogMessageEventHandler(log_LogMessage); log.Start(); DeviceManagement.NetworkConnected += connectionHandler; aliveServers = new ObjectCache(7000); receiveHandler = new MessageEventHandler(networkNode_MessageReceived); aliveServers.ItemExpired += new ItemExpiredEventHandler(aliveServers_ItemExpired); ClientID = Guid.NewGuid(); networkNode = new NetworkNode(ClientID, IPAddress.Any, SensorShareConfig.CommunicationPort); networkNode.MessageReceived += receiveHandler; }
/// <summary> /// Creates a new instance of the <see cref="InspectorCore"/> class. /// </summary> /// <param name="messageHandler">The <see cref="MessageEventHandler"/> for sending messages to the logger.</param> internal InspectorCore(MessageEventHandler messageHandler) { this.messageHandler = messageHandler; }
/// <summary> /// Constructor for all compiler core. /// </summary> /// <param name="intermediate">The Intermediate object representing compiled source document.</param> /// <param name="tableDefinitions">The loaded table definition collection.</param> /// <param name="extensions">The WiX extensions collection.</param> /// <param name="messageHandler">The message handler.</param> internal CompilerCore(Intermediate intermediate, TableDefinitionCollection tableDefinitions, Hashtable extensions, MessageEventHandler messageHandler, XmlSchema schema) { this.tableDefinitions = tableDefinitions; this.extensions = extensions; this.intermediate = intermediate; this.MessageHandler = messageHandler; this.schema = schema; }