public ConnectionServer(IPAddress addr, int port, MessageReceivedCallback callback, APPLICATION_DATA appData) { m_MessageReceviedCallback = callback; m_ip_port = port; m_IPAddr = addr; m_AppData = appData; m_Log = (ErrorLog)m_AppData.Logger; string ViewerPassword; string AdminPassword; try { ViewerPassword = UserSettings.Get(UserSettingTags.PWLPRServiceViewer); if (ViewerPassword == null) { m_Log.Log("ViewerPW is null", ErrorLog.LOG_TYPE.INFORMATIONAL); } m_Log.Log("viewer pw = " + ViewerPassword, ErrorLog.LOG_TYPE.INFORMATIONAL); m_Log.Log("user path = " + UserSettings.GetAppPath(), ErrorLog.LOG_TYPE.INFORMATIONAL); if (ViewerPassword == null) { ViewerPassword = "******"; } else { ViewerPassword = Encryption.DecryptText(ViewerPassword); } AdminPassword = UserSettings.Get(UserSettingTags.PWLPRServiceAdmin); if (AdminPassword == null) { AdminPassword = "******"; } else { AdminPassword = Encryption.DecryptText(AdminPassword); } m_AppData.ServiceAdminPW = AdminPassword; m_AppData.ServiceViewPW = ViewerPassword; m_Clients = new List <ClientConnection>();; listner = new TcpListener(addr, 13000); listner.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);// this line is key, or else you get an exception because the OS does not release the socket if you re-start listner.Start(); StartClientConnectWaitThread(); } catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); Stop(); } }
/// <summary> /// Create subscription against the Topic. After creation, topic react as subscriber, now it recieve messages from server. /// </summary> /// <param name="onMessageReceivedCallback"> Callback for message recceived from topic</param> /// <returns></returns> public ITopicSubscription CreateSubscription(MessageReceivedCallback onMessageReceivedCallback) { try { _readerWriterLock.AcquireReaderLock(Timeout.Infinite); if (_isDisposed) { throw new Exception(string.Format("Topic '{0}' is disposed.", Name)); } if (onMessageReceivedCallback == null) { throw new ArgumentNullException("onMessageReceivedCallback"); } TopicSubscription topicSubscription = new TopicSubscription(this, onMessageReceivedCallback); Subscribe(topicSubscription); lock (_subscriptions) { _subscriptions.Add(topicSubscription.SubscriberId, topicSubscription); } _parent.OnSubscriptionCreated(this, topicSubscription); return(topicSubscription); } finally { _readerWriterLock.ReleaseReaderLock(); } }
public ReceiveMessageState Init(Socket socket, object state, MessageReceivedCallback callback) { Socket = socket; State = state; Callback = callback; return(this); }
internal virtual void OnMessageRecieved(MessageEventArgs args) { try { if (_evtMessageReceived != null) { Delegate[] list = _evtMessageReceived.GetInvocationList(); foreach (Delegate t in list) { MessageReceivedCallback cb = t as MessageReceivedCallback; if (cb != null) { #if !NETCORE cb.BeginInvoke(this, args, null, null); #elif NETCORE //TODO: ALACHISOFT (BeginInvoke is not supported in .Net Core thus using TaskFactory) TaskFactory factory = new TaskFactory(); Task task = factory.StartNew(() => cb(this, args)); #endif } } } } catch (Exception ex) { } }
private void EnqueueResponse(MqttCommand command) { MessageReceivedCallback recv = OnMessageReceived; switch (command.CommandMessage) { case Types.CommandMessage.CONNECT: if (recv != null) { recv(this, new ClientCommandEventArgs(new ConnAck())); } break; case Types.CommandMessage.PINGREQ: if (SendPingResponses) { if (recv != null) { recv(this, new ClientCommandEventArgs(new PingResp())); } } break; case Types.CommandMessage.DISCONNECT: break; default: throw new NotImplementedException(); } }
/// <summary> /// /// </summary> /// <param name="topic"></param> /// <param name="messageReceivedCallback"></param> public TopicSubscription(Topic topic, string subscriptionName, SubscriptionPolicyType subscriptionPolicy, MessageReceivedCallback messageReceivedCallback) { _topic = topic; _subscriptionName = subscriptionName; _subscriptionPolicyType = subscriptionPolicy; _evtMessageReceived += messageReceivedCallback; }
private int m_taskId = 4120; // This is incremented to fabricate changing IDs in messages /// <summary> /// Constructor. /// </summary> public FakeAmqpClient(ConnectionEventCallback connCb, MessageReceivedCallback msgCb) : base(connCb, msgCb) { // Create timer to send messages periodically m_timer = new System.Timers.Timer(); m_timer.Elapsed += M_timer_Elapsed; m_timer.Interval = 4000; // unit: ms m_timer.AutoReset = true; }
private void initOSC(MessageReceivedCallback messageReceivedCallback) { this.mrc = messageReceivedCallback; solidworksPlugin = new IPEndPoint(IPAddress.Loopback, SENDPORT); openFrameworks = new IPEndPoint(IPAddress.Loopback, SENDPORT); server = new OscServer(TransportType.Udp, IPAddress.Loopback, RECEIVEPORT); server.FilterRegisteredMethods = false; server.MessageReceived += new EventHandler <OscMessageReceivedEventArgs>(receivedMessage); server.ConsumeParsingExceptions = false; server.Start(); }
public IDurableTopicSubscription CreateSubscriptions(string topicName, MessageReceivedCallback messageReceivedCallback) { // cretews a subscription against a topic try { ITopic topic = GetTopic(topicName); return(topic.CreateDurableSubscription(Guid.NewGuid().ToString(), SubscriptionPolicy.Exclusive, messageReceivedCallback, null)); } catch { throw; } }
/// <summary> /// Create subscription against the Topic. After creation, topic react as subscriber, now it receive messages from server. /// </summary> /// <param name="onMessageReceivedCallback"> Callback for message received from topic</param> /// <returns></returns> public ITopicSubscription CreateSubscription(MessageReceivedCallback onMessageReceivedCallback) { if (_isDisposed) { throw new OperationFailedException(ErrorCodes.PubSub.TOPIC_DISPOSED, ErrorMessages.GetErrorMessage(ErrorCodes.PubSub.TOPIC_DISPOSED, Name)); } if (onMessageReceivedCallback == null) { throw new ArgumentNullException("onMessageReceivedCallback"); } string subscriptionName = new Shorter().GuidString; return(RegisterSubscriptions(subscriptionName, onMessageReceivedCallback)); }
public ITopicSubscription CreateEventSubscription(MessageReceivedCallback onMessageReceivedCallback) { if (_isDisposed) { throw new OperationFailedException(ErrorCodes.PubSub.TOPIC_DISPOSED, ErrorMessages.GetErrorMessage(ErrorCodes.PubSub.TOPIC_DISPOSED, Name)); } if (onMessageReceivedCallback == null) { throw new ArgumentNullException("onMessageReceivedCallback"); } string subscriptionName = SubscriptionInfo.EventsSubscriptionName; return(RegisterSubscriptions(subscriptionName, onMessageReceivedCallback, SubscriptionPolicyType.EventSubscription)); }
public CBackendController(string server_url, ushort port, RequestUsersCallBack request_users_callback, LoginRequestCallback login_request_callback, MessageStatusChangeCallback msg_status_changed_callback, MessageReceivedCallback msg_received_callback) { m_native_object = create_backend_instance(server_url, port); m_request_users_callback = request_users_callback; m_login_request_callback = login_request_callback; m_msg_status_changed_callback = msg_status_changed_callback; m_msg_received_callback = msg_received_callback; set_msg_status_changed_callback(m_native_object, m_msg_status_changed_callback); set_msg_received_callback(m_native_object, m_msg_received_callback); }
public void Connect(System.Net.IPEndPoint endpoint) { TcpClient client = new TcpClient(); client.Connect(endpoint); _network.Start(client, (MqttCommand cmd) => { MessageReceivedCallback recv = OnMessageReceived; if (recv != null) { recv(this, new ClientCommandEventArgs(cmd)); } }); }
internal ITopicSubscription RegisterSubscriptions(string subscriptionName, MessageReceivedCallback onMessageReceivedCallback, SubscriptionPolicyType subscriptionPolicy = SubscriptionPolicyType.NonDurableExclusiveSubscription, TimeSpan?timeSpan = default(TimeSpan?)) { try { _readerWriterLock.AcquireReaderLock(Timeout.Infinite); SubscriptionIdentifier subscriptionIdentifier = new SubscriptionIdentifier(subscriptionName, subscriptionPolicy); TopicSubscription topicSubscription = GetExistingSubscription(subscriptionIdentifier, subscriptionPolicy); if (topicSubscription == null) { topicSubscription = new TopicSubscription(this, subscriptionName, subscriptionPolicy, onMessageReceivedCallback); DateTime creationTime = DateTime.Now; topicSubscription.CreationTime = creationTime.Ticks; topicSubscription.SetSubscriptionPolicy(subscriptionPolicy); if (timeSpan == null) { topicSubscription.Expiration = TimeSpan.MaxValue.Ticks; } else { topicSubscription.Expiration = timeSpan.Value.Ticks; } Subscribe(topicSubscription, subscriptionPolicy); lock (_subscriptions) { var existingSubscription = GetExistingSubscription(subscriptionIdentifier, subscriptionPolicy); if (existingSubscription == null) { _subscriptions.Add(subscriptionIdentifier, topicSubscription); } else { return(existingSubscription); } } _parent.OnSubscriptionCreated(this, topicSubscription); } return(topicSubscription); } finally { _readerWriterLock.ReleaseReaderLock(); } }
public ConnectionServer( IPAddress addr, int port, MessageReceivedCallback callback, APPLICATION_DATA appData) { m_MessageReceviedCallback = callback; m_ip_port = port; m_IPAddr = addr; m_AppData = appData; m_Log = (ErrorLog)m_AppData.Logger; string ViewerPassword; string AdminPassword; try { ViewerPassword = UserSettings.Get(UserSettingTags.PWLPRServiceViewer); if (ViewerPassword == null) m_Log.Log("ViewerPW is null", ErrorLog.LOG_TYPE.INFORMATIONAL); m_Log.Log("viewer pw = " + ViewerPassword, ErrorLog.LOG_TYPE.INFORMATIONAL); m_Log.Log("user path = " + UserSettings.GetAppPath(), ErrorLog.LOG_TYPE.INFORMATIONAL); if (ViewerPassword == null) ViewerPassword = "******"; else ViewerPassword = Encryption.DecryptText(ViewerPassword); AdminPassword = UserSettings.Get(UserSettingTags.PWLPRServiceAdmin); if (AdminPassword == null) AdminPassword = "******"; else AdminPassword = Encryption.DecryptText(AdminPassword); m_AppData.ServiceAdminPW = AdminPassword; m_AppData.ServiceViewPW = ViewerPassword; m_Clients = new List<ClientConnection>(); ; listner = new TcpListener(addr, 13000); listner.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);// this line is key, or else you get an exception because the OS does not release the socket if you re-start listner.Start(); StartClientConnectWaitThread(); } catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); Stop(); } }
/// <summary> /// This method initializes the specified cache and subscribes to the specified topic for the published messages on it. /// </summary> /// <param name="cacheName">The name of the cache to initialize.</param> /// <param name="topicName">The name of the topic to subscribe to.</param> /// <param name="messageReceivedCallback">The callback which will be invoked when a message is published on the topic.</param> public void Subscribe(string cacheName, string topicName, MessageReceivedCallback messageReceivedCallback) { // Initializes the cache. _cache = CacheManager.GetCache(cacheName); // Gets the topic. _topic = _cache.MessagingService.GetTopic(topicName); // Creates the topic if it doesn't exist. if (_topic == null) { _topic = _cache.MessagingService.CreateTopic(topicName); } // Subscribes to the topic. _topic.CreateSubscription(messageReceivedCallback); }
public List<SignalServiceEnvelope> retrieveMessages(MessageReceivedCallback callback) { List<SignalServiceEnvelope> results = new List<SignalServiceEnvelope>(); List<SignalServiceEnvelopeEntity> entities = socket.getMessages(); foreach (SignalServiceEnvelopeEntity entity in entities) { SignalServiceEnvelope envelope = new SignalServiceEnvelope((int)entity.getType(), entity.getSource(), (int)entity.getSourceDevice(), entity.getRelay(), (int)entity.getTimestamp(), entity.getMessage(), entity.getContent()); callback.onMessage(envelope); results.Add(envelope); socket.acknowledgeMessage(entity.getSource(), entity.getTimestamp()); } return results; }
public async Task <List <TextSecureEnvelope> > retrieveMessages(MessageReceivedCallback callback) { List <TextSecureEnvelope> results = new List <TextSecureEnvelope>(); List <TextSecureEnvelopeEntity> entities = await socket.getMessages(); foreach (TextSecureEnvelopeEntity entity in entities) { TextSecureEnvelope envelope = new TextSecureEnvelope(entity.getType(), entity.getSource(), entity.getSourceDevice(), entity.getRelay(), entity.getTimestamp(), entity.getMessage(), entity.getContent()); callback.onMessage(envelope); results.Add(envelope); socket.acknowledgeMessage(entity.getSource(), entity.getTimestamp()); } return(results); }
public ClientConnection(Socket socket, string ipAddr, MessageReceivedCallback messageReceived, ConnectionClosedCallBack closedCB, APPLICATION_DATA appData) { ipAddress = ipAddr; m_AppData = appData; m_Log = (ErrorLog)m_AppData.Logger; try { protocol = new RCS_Protocol.RCS_Protocol(m_AppData, ipAddr); MessageReceived = messageReceived; ConnectionClosed = closedCB; connection = socket; connection.Blocking = true; } catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); Close(); ConnectionClosed(this); } }
public IDurableTopicSubscription CreateRelevantSubscribtions(string topicName, MessageReceivedCallback messageReceivedCallback) { // initializes subscribers to two subscriptions try { return(Cache.CreateSubscriptions(topicName, messageReceivedCallback)); } catch { throw; } }
internal static extern WebRTCErrorCode SetMessageReceivedCb(IntPtr dataChanndelHandle, MessageReceivedCallback callback, IntPtr userData = default);
static private extern void set_msg_received_callback(IntPtr pObject, [MarshalAs(UnmanagedType.FunctionPtr)] MessageReceivedCallback pfResult);
public ClientConnection(Socket socket, string ipAddr, MessageReceivedCallback messageReceived,ConnectionClosedCallBack closedCB, APPLICATION_DATA appData ) { ipAddress = ipAddr; m_AppData = appData; m_Log = (ErrorLog)m_AppData.Logger; try { protocol = new RCS_Protocol.RCS_Protocol(m_AppData, ipAddr); MessageReceived = messageReceived; ConnectionClosed = closedCB; connection = socket; connection.Blocking = true; } catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); Close(); ConnectionClosed(this); } }
/// <summary> /// Constructor. /// </summary> /// <param name="connCb">Callback for connection-related events excluding errors.</param> /// <param name="msgCb">Callback for the reception of messages.</param> protected AmqpClientBase(ConnectionEventCallback connCb, MessageReceivedCallback msgCb) { b_connectionEventCallback = connCb; b_messageReceivedCallback = msgCb; } // AmqpClientBase
public static void ReceiveMessage(Socket socket, object state, MessageReceivedCallback callback) { ReceiveMessageState data = ReceiveCache.Get().Init(socket, state, callback); ReceiveMessageBase(data); }
public OSCCommunicator(MessageReceivedCallback messageReceivedCallback) { initOSC(messageReceivedCallback); }
public ReceiveMessageState Init(Socket socket, object state, MessageReceivedCallback callback) { Socket = socket; State = state; Callback = callback; return this; }
internal void OnMessageReceived(ChatType chatType, string message, DateTime timestamp) { MessageReceivedCallback?.Invoke(this, chatType, message, timestamp); }
public static void ReceiveHandshake(Socket socket, object state, MessageReceivedCallback callback) { var data = ReceiveCache.Get().Init(socket, state, callback); HandshakeMessageBase(data); }
public async Task<List<TextSecureEnvelope>> retrieveMessages(MessageReceivedCallback callback) { List<TextSecureEnvelope> results = new List<TextSecureEnvelope>(); List<TextSecureEnvelopeEntity> entities = await socket.getMessages(); foreach (TextSecureEnvelopeEntity entity in entities) { TextSecureEnvelope envelope = new TextSecureEnvelope(entity.getType(), entity.getSource(), entity.getSourceDevice(), entity.getRelay(), entity.getTimestamp(), entity.getMessage(), entity.getContent()); callback.onMessage(envelope); results.Add(envelope); socket.acknowledgeMessage(entity.getSource(), entity.getTimestamp()); } return results; }
public SNEP_Server(MessageReceivedCallback MessageReceived) : base("SNEP Server", SNEP.SERVER_PORT, SNEP.SERVER_NAME) /* SNEP server address is 0x04 */ { OnMessageReceived = MessageReceived; OnNdefReceived = null; }
/// <summary> /// Constructor. /// </summary> /// <param name="connCb">Callback for connection-related events excluding connection failure.</param> /// <param name="msgCb">Callback for the reception of messages.</param> public AmqpClient(ConnectionEventCallback connCb, MessageReceivedCallback msgCb) : base(connCb, msgCb) { m_connectionHandler = new Thread(ConnectionHandlerProgram); m_connectionHandler.Start(); } // AmqpClient
internal void SetMessageReceivedCallback(MessageReceivedCallback messageReceivedCallback) { this.messageReceivedCallback = messageReceivedCallback; }
public TopicSubscription(Topic topic, MessageReceivedCallback messageReceivedCallback) { _topic = topic; _subscriberId = new Shorter().GuidString; _evtMessageReceived += messageReceivedCallback; }