private void InitializeClient() { MonitoringInitializationMessage queueItems = new MonitoringInitializationMessage(MockQueueItems.items.Values.ToList(), HeartBeatPublisher.ipAddress.ToString(), HeartBeatPublisher.Port); clientState = PublisherClientState.Initializing; // make use of concurrent bag SendAsync(queueItems); }
private void InitializationCallback(IAsyncResult result) { if (result.IsCompleted) { //Socket client = (Socket)result.AsyncState; StateObject state = (StateObject)result.AsyncState; int bytesSent = state.workSocket.EndSend(result); if (itemsChangedInInitialization.Count > 0) { List <QueueItemStateChangeMessage> messagesList = itemsChangedInInitialization.ToList(); SendAsync(new ChangedItemsWhileInitializingMessage() { items = messagesList }); } clientState = PublisherClientState.Connected; } else { throw new Exception(); } }
public void Close() { clientState = PublisherClientState.Disconnected; clientSocket.Close(); }