/// <summary> /// Adds the message task. /// </summary> /// <param name="messageTask">The message task.</param> internal void AddMessageTask(MessageTask messageTask) { if (messageTask == null) { ThrowHelper.ThrowArgumentNullException("messageTask"); } if (LOGGER.IsDebugEnabled) { LOGGER.Debug(string.Format("NETWORK_CONNECTION({0}), queuing a new message to send. {1}", mNetworkStream.Id, messageTask.Message.ToString())); } Queue <MessageTask> queue = this.mMessageQueues[(int)messageTask.Message.Priority]; lock (queue) { queue.Enqueue(messageTask); } Raiser.CallDelegatorBySync(MessageSendBefore, new object[] { this, new MessageSendEventArgs(messageTask, false) }); lock (LOCK_OBJECT) { mTotalMessagesToSend++; if (mTotalMessagesToSend == 1) { THREADPOOL.QueueUserWorkItem(new WaitCallback(Send)); } } }
private void Event_KeyUp(object sender, KeyEventArgs e) { ListSpecialized <EventHandler <SubscribedKeyPressEventArgs> > subscribeds = null; KeysSubscription k = new KeysSubscription(e.KeyCode, e.Alt, e.Control, e.Shift); lock (mKeysSubscriptions) { if (mKeysSubscriptions.ContainsKey(k)) { subscribeds = new ListSpecialized <EventHandler <SubscribedKeyPressEventArgs> >(mKeysSubscriptions[k]); } } if (subscribeds != null) { SubscribedKeyPressEventArgs arg = new SubscribedKeyPressEventArgs(k); foreach (EventHandler <SubscribedKeyPressEventArgs> handler in subscribeds) { Raiser.CallDelegatorBySync(handler, new object[] { this, arg }); } } else { IRemoteDesktopClientInternal proxy = mProxy; if (proxy != null && proxy.IsActive) { try { proxy.ClientSendKeyEvent(new KeyboardEventArgs(KeyboardEventTypeEnum.Up, e.KeyCode)); } catch (Exception) { } } //LogKeyEvent(sender, "KEY-UP", e); } }
private void HandleDisconnection() { if (this.mConnected) { this.mConnected = false; Raiser.CallDelegatorBySync(Disconnect, new object[] { this, EventArgs.Empty }); } }
public static bool UnregisterChannel(Channel channel) { if (channel == null) { throw new ArgumentNullException("channel"); } Raiser.CallDelegatorBySync(UnregisterChannelEvent, new object[] { mChannelServicesSingleton, new ChannelRegistrationEventArgs(channel) }); return(mChannels.Remove(channel)); }
static void Main() { r = new Raiser(); r.Raise(3); //Event raised without subscribers new Listener(r); //This object is created only to run the constructor. r.Raise(3); //Event raised with subscribers. }
/// <summary> /// Raises the event. /// </summary> /// <param name="del">The delegae (event).</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void RaiseEvent(Delegate del, object sender, EventArgs e) { if (EventSyncInvocation) { Raiser.CallDelegatorBySync(del, new object[] { sender, e }, EventUIInvocation, EventParallelInvocation); } else { Raiser.CallDelegatorByAsync(del, new object[] { sender, e }, EventUIInvocation, EventParallelInvocation); } }
private void OnPingResult(PingResultEnum result) { if (SyncEventRaiser) { Raiser.CallDelegatorBySync(EventPingResult, new object[] { this, new PingResultEventArgs(result) }, UIInvocationOnEvents, ParallelInvocationOnEvents); } else { Raiser.CallDelegatorByAsync(EventPingResult, new object[] { this, new PingResultEventArgs(result) }, UIInvocationOnEvents, ParallelInvocationOnEvents); } }
private void OnPingResult(int receivedBytes, int responseTime) { if (SyncEventRaiser) { Raiser.CallDelegatorBySync(EventPingResult, new object[] { this, new PingResultEventArgs(mRemoteIpAddress, receivedBytes, responseTime) }, UIInvocationOnEvents, ParallelInvocationOnEvents); } else { Raiser.CallDelegatorByAsync(EventPingResult, new object[] { this, new PingResultEventArgs(mRemoteIpAddress, receivedBytes, responseTime) }, UIInvocationOnEvents, ParallelInvocationOnEvents); } }
private void OnFileRead() { mReadCounter++; int percent = Convert.ToInt32(Convert.ToDouble(this.Position) / (Convert.ToDouble(this.Length) / 100d)); if (percent != mLastPercent || mReadCounter == 3) { mReadCounter = 0; mLastPercent = percent; Raiser.CallDelegatorBySync(EventFileRead, new object[] { this, new FileStreamProgressEventArgs(this.Length, this.Position, percent) }); } }
private void Proxy_Disconnected(object sender, DisconnectEventArgs e) { mProxy.Dispose(); mMouseMoveWaitEvent.Set(); UnsubscribeEvents(); ClipboardEventManager.Instance.EventClipboardChanged -= new EventHandler <Native.Hooks.ClipboardChangedEventArgs>(ClipboardChangedEventHandler); DrawInitialBlackBackground(); lock (mLockEventObject) { Raiser.CallDelegatorBySync(EventConnectionStateChange, new object[] { this, new ConnectionStateChangeEventArgs(false) }); } }
/// <summary> /// Internals the on receive request message. /// </summary> /// <param name="channel">The channel.</param> /// <param name="e">The <see cref="Forge.Net.Remoting.Channels.ReceiveMessageEventArgs"/> instance containing the event data.</param> protected void InternalOnReceiveRequestMessage(Channel channel, ReceiveMessageEventArgs e) { if (LOGGER.IsDebugEnabled) { LOGGER.Debug(string.Format("{0}-Event, raise event ReceiveMessage (BEGIN). SessionId: '{1}', {2}", this.GetType().Name, e.SessionId, e.Message.ToString())); } Raiser.CallDelegatorBySync(ReceiveMessage, new object[] { channel, e }); if (LOGGER.IsDebugEnabled) { LOGGER.Debug(string.Format("{0}-Event, raise event ReceiveMessage (END). SessionId: '{1}', {2}", this.GetType().Name, e.SessionId, e.Message.ToString())); } }
private static void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemoteDesktopConfiguration.Settings.CategoryPropertyItems, CONFIG_ROOT); if (rootItem != null) { int mouseMoveSendingInterval = Consts.DEFAULT_MOUSE_MOVE_SEND_INTERVAL; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_MOUSE_MOVE_SEND_INTERVAL, 0, int.MaxValue, ref mouseMoveSendingInterval)) { MouseMoveSendInterval = mouseMoveSendingInterval; } } Raiser.CallDelegatorBySync(EventConfigurationChanged, new object[] { null, EventArgs.Empty }); }
public static bool RegisterChannel(Channel channel) { if (channel == null) { throw new ArgumentNullException("channel"); } if (!channel.IsInitialized) { throw new InitializationException("Channel has not been initialized."); } bool result = false; if (!mChannels.Contains(channel)) { result = true; mChannels.Add(channel); Raiser.CallDelegatorBySync(RegisterChannelEvent, new object[] { mChannelServicesSingleton, new ChannelRegistrationEventArgs(channel) }); } return(result); }
/// <summary> /// Raises the <see cref="E:ConnectionStateChange" /> event. /// </summary> /// <param name="e">The <see cref="ConnectionStateChangeEventArgs"/> instance containing the event data.</param> protected virtual void OnConnectionStateChange(ConnectionStateChangeEventArgs e) { if (e.IsConnected) { reconnectToolStripMenuItem.Enabled = false; disconnectToolStripMenuItem.Enabled = true; } else { reconnectToolStripMenuItem.Enabled = true; disconnectToolStripMenuItem.Enabled = false; fullScreenToolStripMenuItem.Enabled = false; pauseToolStripMenuItem.Enabled = false; pauseToolStripMenuItem.Text = Resources.cmPause; setQualityToolStripMenuItem.Enabled = false; refreshScreenToolStripMenuItem.Enabled = false; sendAFileToolStripMenuItem.Enabled = false; rdpClient.UnsubscribeForKeys(new KeysSubscription(Keys.F, false, true, true), new EventHandler <SubscribedKeyPressEventArgs>(FullScreenHandler)); } Raiser.CallDelegatorBySync(EventConnectionStateChange, new object[] { e }); }
public void Connect(string channelId, AddressEndPoint endPoint) { DoDisposeCheck(); if (string.IsNullOrEmpty(channelId)) { ThrowHelper.ThrowArgumentNullException("channelId"); } if (endPoint == null) { ThrowHelper.ThrowArgumentNullException("endPoint"); } Disconnect(); ProxyFactory <IRemoteDesktop> factory = new ProxyFactory <IRemoteDesktop>(channelId, endPoint); lock (mLockEventObject) { mProxy = (IRemoteDesktopClientInternal)factory.CreateProxy(); mProxy.Owner = this; Raiser.CallDelegatorBySync(EventConnectionStateChange, new object[] { this, new ConnectionStateChangeEventArgs(true) }); mProxy.Disconnected += new EventHandler <DisconnectEventArgs>(Proxy_Disconnected); } }
public void Raise() { Raiser.CallDelegatorByAsync(TestEvent, new object[] { this, EventArgs.Empty }, true); }
public static void Initialize() { if (!mInitialized) { Raiser.CallDelegatorBySync(EventInitialization, new object[] { null, new ServiceInitializationStateEventArgs(ServiceInitializationStateEnum.Before) }); ChannelServices.Initialize(); if (LOGGER.IsInfoEnabled) { LOGGER.Info("Initializing ServiceBase services."); } CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemotingConfiguration.Settings.CategoryPropertyItems, "Services"); if (pi != null) { IEnumerator <CategoryPropertyItem> iterator = pi.GetEnumerator(); try { while (iterator.MoveNext()) { pi = iterator.Current; if (string.IsNullOrEmpty(pi.Id)) { throw new InvalidConfigurationException("Contract type not definied. Empty item found in configuration."); } Type contractType = null; Type defaultImplementationType = null; try { contractType = TypeHelper.GetTypeFromString(pi.Id); if (ContractDescriptors.ContainsKey(contractType)) { throw new InvalidConfigurationException(String.Format("Duplicated contract type configuration found in services. Contract: {0}", contractType.FullName)); } ContractValidator.ValidateContractIntegrity(contractType); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve contract type: {0}", pi.Id), ex); } if (!string.IsNullOrEmpty(pi.EntryValue)) { try { defaultImplementationType = TypeHelper.GetTypeFromString(pi.EntryValue); if (!contractType.IsAssignableFrom(defaultImplementationType)) { throw new InvalidProxyImplementationException(String.Format("Provided default implementation type '{0}' does not implement contract interface '{1}'.", defaultImplementationType.FullName, contractType.FullName)); } ImplementationValidator.ValidateImplementationIntegrity(defaultImplementationType); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve implementation type: {0}", pi.EntryValue), ex); } } ContractServiceSideDescriptor descriptor = new ContractServiceSideDescriptor(contractType, defaultImplementationType); IEnumerator <CategoryPropertyItem> channelIterator = pi.GetEnumerator(); while (channelIterator.MoveNext()) { CategoryPropertyItem channelImplementationItem = channelIterator.Current; if (string.IsNullOrEmpty(channelImplementationItem.Id)) { throw new InvalidConfigurationValueException(String.Format("Channel identifier is missing from a configuration item of the contract '{0}'", pi.Id)); } if (string.IsNullOrEmpty(channelImplementationItem.EntryValue)) { throw new InvalidConfigurationValueException(String.Format("Implementation type is missing from a configuration item of the contract '{0}'", pi.Id)); } if (!ChannelServices.IsChannelRegistered(channelImplementationItem.Id)) { throw new InvalidConfigurationValueException(String.Format("Unregistered channel provided '{0}' in configuration section of the contract: {1}.", channelImplementationItem.Id, pi.Id)); } Type type = null; try { type = TypeHelper.GetTypeFromString(channelImplementationItem.EntryValue); if (!contractType.IsAssignableFrom(type)) { throw new InvalidProxyImplementationException(String.Format("Provided implementation type '{0}' does not implement contract interface '{1}'.", type.FullName, contractType.FullName)); } ImplementationValidator.ValidateImplementationIntegrity(type); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve non-default implementation type: {0} for contract: {1} for the channel: {2}", channelImplementationItem.EntryValue, pi.Id, channelImplementationItem.Id), ex); } if (descriptor.ImplementationPerChannel.ContainsKey(channelImplementationItem.Id)) { throw new InvalidConfigurationException(String.Format("Duplicated channel identifier at contract '{0}'.", pi.Id)); } descriptor.ImplementationPerChannel.Add(channelImplementationItem.Id, type); } ContractDescriptors.Add(contractType, descriptor); } ChannelServices.StartListeningChannels(); } catch (Exception ex) { ContractDescriptors.Clear(); throw ex; } } mInitialized = true; if (LOGGER.IsInfoEnabled) { LOGGER.Info("ServiceBase services successfully initialized."); } Raiser.CallDelegatorBySync(EventInitialization, new object[] { null, new ServiceInitializationStateEventArgs(ServiceInitializationStateEnum.After) }); } }
/// <summary> /// Raises the on configuration changed. /// </summary> /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param> protected virtual void RaiseOnConfigurationChanged(EventArgs e) { Raiser.CallDelegatorBySync(OnConfigurationChanged, new object[] { this, e }, false, false); }
/// <summary> /// Called when [property changed]. /// </summary> /// <param name="propertyName">Name of the property.</param> protected virtual void OnPropertyChanged(string propertyName) { this.isChanged = true; Raiser.CallDelegatorBySync(propertyChangedDelegate, new object[] { this, new PropertyChangedEventArgs(propertyName) }, false, false); }
/// <summary> /// Called when [property changing]. /// </summary> /// <param name="propertyName">Name of the property.</param> protected virtual void OnPropertyChanging(string propertyName) { Raiser.CallDelegatorBySync(propertyChangingDelegate, new object[] { this, new PropertyChangingEventArgs(propertyName) }, false, false); }
internal void OnNetworkPeerConnected(ConnectionEventArgs e) { Raiser.CallDelegatorBySync(NetworkPeerConnected, new object[] { this, e }); }
/// <summary> /// Handles the Click event of the btConnect control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected virtual void btConnect_Click(object sender, EventArgs e) { this.SelectedProvider = lvServices.SelectedItems[0].Tag as ServiceProvider; Raiser.CallDelegatorBySync(EventConnect, new object[] { this, EventArgs.Empty }); }
public static void Initialize() { if (!mInitialized) { Raiser.CallDelegatorBySync(EventInitialization, new object[] { null, new ServiceInitializationStateEventArgs(ServiceInitializationStateEnum.Before) }); ChannelServices.Initialize(); if (LOGGER.IsInfoEnabled) { LOGGER.Info("Initializing client proxy services."); } CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemotingConfiguration.Settings.CategoryPropertyItems, "Clients"); if (pi != null) { try { IEnumerator <CategoryPropertyItem> iterator = pi.GetEnumerator(); while (iterator.MoveNext()) { pi = iterator.Current; if (string.IsNullOrEmpty(pi.Id)) { throw new InvalidConfigurationException("Contract type not definied. Empty item found in configuration."); } Type contractType = null; String defaultChannelId = null; Type defaultProxyType = null; try { contractType = TypeHelper.GetTypeFromString(pi.Id); if (mContractDescriptors.ContainsKey(contractType)) { throw new InvalidConfigurationException(String.Format("Duplicated contract type configuration found in clients. Contract: {0}", contractType.FullName)); } ContractValidator.ValidateContractIntegrity(contractType); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve contract type: {0}", pi.Id), ex); } { CategoryPropertyItem defaultChannelIdPropertyItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemotingConfiguration.Settings.CategoryPropertyItems, String.Format("Clients/{0}/Defaults/DefaultChannelId", pi.Id)); if (defaultChannelIdPropertyItem != null) { defaultChannelId = defaultChannelIdPropertyItem.EntryValue; if (string.Empty.Equals(defaultChannelId)) { defaultChannelId = null; } } } { CategoryPropertyItem defaultProxyTypePropertyItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemotingConfiguration.Settings.CategoryPropertyItems, String.Format("Clients/{0}/Defaults/DefaultProxyType", pi.Id)); if (defaultProxyTypePropertyItem != null) { if (defaultProxyTypePropertyItem.EntryValue != null && !string.Empty.Equals(defaultProxyTypePropertyItem.EntryValue)) { try { defaultProxyType = TypeHelper.GetTypeFromString(defaultProxyTypePropertyItem.EntryValue); ImplementationValidator.ValidateProxyIntegration(defaultProxyType); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve proxy type: {0} for contract: {1}", defaultProxyTypePropertyItem.EntryValue, pi.Id), ex); } } } } if (!(defaultChannelId == null && defaultProxyType == null)) { if (defaultChannelId == null || defaultProxyType == null) { throw new InvalidConfigurationException(String.Format("Both of 'DefaultChannelId' and 'DefaultProxyType' values are must be filled in configuration. Contract type: {0}", pi.Id)); } if (!contractType.IsAssignableFrom(defaultProxyType)) { throw new InvalidProxyImplementationException(String.Format("Provided default proxy type '{0}' does not implement contract interface '{1}'.", defaultProxyType.FullName, contractType.FullName)); } } ContractClientSideDescriptor descriptor = new ContractClientSideDescriptor(contractType, defaultChannelId, defaultProxyType); { CategoryPropertyItem customDefinitionsPropertyItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemotingConfiguration.Settings.CategoryPropertyItems, String.Format("Clients/{0}/CustomDefinitions", pi.Id)); if (customDefinitionsPropertyItem != null) { IEnumerator <CategoryPropertyItem> customDefinitionsIterator = customDefinitionsPropertyItem.GetEnumerator(); while (customDefinitionsIterator.MoveNext()) { CategoryPropertyItem channelProxyItem = customDefinitionsIterator.Current; if (string.IsNullOrEmpty(channelProxyItem.Id)) { throw new InvalidConfigurationValueException(String.Format("Channel identifier is missing from a configuration item at the CustomDefinitions of the contract '{0}'", pi.Id)); } if (string.IsNullOrEmpty(channelProxyItem.EntryValue)) { throw new InvalidConfigurationValueException(String.Format("Proxy type is missing from a configuration item at the CustomDefinitions of the contract '{0}'", pi.Id)); } if (!ChannelServices.IsChannelRegistered(channelProxyItem.Id)) { throw new InvalidConfigurationValueException(String.Format("Unregistered channel provided '{0}' in CustomDefinitions configuration section of the contract: {1}.", channelProxyItem.Id, pi.Id)); } Type type = null; try { type = TypeHelper.GetTypeFromString(channelProxyItem.EntryValue); if (!contractType.IsAssignableFrom(type)) { throw new InvalidProxyImplementationException(String.Format("Provided proxy type '{0}' does not implement contract interface '{1}'.", type.FullName, contractType.FullName)); } ImplementationValidator.ValidateProxyIntegration(type); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve non-default proxy type: {0} for contract: {1} for the channel: {2}", channelProxyItem.EntryValue, pi.Id, channelProxyItem.Id), ex); } if (descriptor.ImplementationPerChannel.ContainsKey(channelProxyItem.Id)) { throw new InvalidConfigurationException(String.Format("Duplicated channel identifier in CustomDefinitions section at contract '{0}'.", pi.Id)); } descriptor.ImplementationPerChannel.Add(channelProxyItem.Id, type); } } } mContractDescriptors.Add(contractType, descriptor); } mSingletonInstance = new ProxyServices(); //if (mContractDescriptors.Count > 0) //{ // mSingletonInstance = new ProxyServices(); //} } catch (Exception ex) { mContractDescriptors.Clear(); throw ex; } } //ChannelServices.startListeningChannels(); mInitialized = true; if (LOGGER.IsInfoEnabled) { LOGGER.Info("Client proxy services successfully initialized."); } Raiser.CallDelegatorBySync(EventInitialization, new object[] { null, new ServiceInitializationStateEventArgs(ServiceInitializationStateEnum.After) }); } }
/// <summary> /// Raises the <see cref="E:SessionStateChange"/> event. /// </summary> /// <param name="e">The <see cref="Forge.Net.Remoting.Channels.SessionStateEventArgs"/> instance containing the event data.</param> protected void OnSessionStateChange(SessionStateEventArgs e) { Raiser.CallDelegatorBySync(SessionStateChange, new object[] { this, e }); }
/// <summary> /// Handles the Click event of the btCancel control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected virtual void btCancel_Click(object sender, EventArgs e) { Raiser.CallDelegatorBySync(EventCancel, new object[] { this, EventArgs.Empty }); }
public Listener(Raiser r) //We have to reach the raiser object and its proxy method. { r.Giveittome(Fun1); r.Giveittome(Fun2); }
public void Fire() { Raiser.CallDelegatorByAsync(OnTest, new object[] { this, EventArgs.Empty }); }
private static void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemoteDesktopConfiguration.Settings.CategoryPropertyItems, CONFIG_ROOT); if (rootItem != null) { AuthenticationModeEnum authMode = AuthenticationModeEnum.OnlyPassword; if (ConfigurationAccessHelper.ParseEnumValue <AuthenticationModeEnum>(rootItem.PropertyItems, CONFIG_AUTHENTICATION_MODE, ref authMode)) { AuthenticationMode = authMode; } string moduleStore = string.Empty; if (ConfigurationAccessHelper.ParseStringValue(rootItem.PropertyItems, CONFIG_AUTHENTICATION_MODULE_STORE, ref moduleStore)) { mAuthenticationModuleStore = moduleStore; } bool propagateOnNetwork = true; if (ConfigurationAccessHelper.ParseBooleanValue(rootItem.PropertyItems, CONFIG_PROPAGATE_ON_NETWORK, ref propagateOnNetwork)) { PropagateServiceOnTheNetwork = propagateOnNetwork; } DesktopShareModeEnum desktopShareMode = DesktopShareModeEnum.Shared; if (ConfigurationAccessHelper.ParseEnumValue <DesktopShareModeEnum>(rootItem.PropertyItems, CONFIG_DESKTOP_SHARE_MODE, ref desktopShareMode)) { DesktopShareMode = desktopShareMode; } bool acceptKeyboardAndMouseInputFromClients = true; if (ConfigurationAccessHelper.ParseBooleanValue(rootItem.PropertyItems, CONFIG_ACCEPT_INPUTS_FROM_CLIENTS, ref acceptKeyboardAndMouseInputFromClients)) { AcceptKeyboardAndMouseInputFromClients = acceptKeyboardAndMouseInputFromClients; } int desktopImageClipWidth = Consts.DEFAULT_DESKTOP_IMAGE_CLIP_SIZE; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_DESKTOP_IMAGE_CLIP_WIDTH, Consts.MINIMAL_CLIP_SIZE, int.MaxValue, ref desktopImageClipWidth)) { DesktopImageClipWidth = desktopImageClipWidth; } int desktopImageClipHeight = Consts.DEFAULT_DESKTOP_IMAGE_CLIP_SIZE; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_DESKTOP_IMAGE_CLIP_WIDTH, Consts.MINIMAL_CLIP_SIZE, int.MaxValue, ref desktopImageClipHeight)) { DesktopImageClipHeight = desktopImageClipHeight; } int clientsPerServiceThreads = Consts.DEFAULT_CLIENTS_PER_SERVICE_THREADS; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_DESKTOP_IMAGE_CLIP_WIDTH, Consts.MINIMAL_CLIENTS_PER_SERVICE_THREADS, int.MaxValue, ref clientsPerServiceThreads)) { ClientsPerServiceThreads = clientsPerServiceThreads; } int maximumFailedLoginAttempt = Consts.DEFAULT_MAXIMUM_FAILED_LOGIN_ATTEMPT; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_MAXIMUM_FAILED_LOGIN_ATTEMPT, 0, int.MaxValue, ref maximumFailedLoginAttempt)) { MaximumFailedLoginAttempt = maximumFailedLoginAttempt; } int blackListTimeout = Consts.DEFAULT_BLACKLIST_TIMEOUT_IN_MINUTES; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_BLACKLIST_TIMEOUT, 0, int.MaxValue, ref blackListTimeout)) { BlackListTimeout = blackListTimeout; } int imageClipQuality = Consts.DEFAULT_IMAGE_CLIP_QUALITY; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_IMAGE_CLIP_QUALITY, 10, 100, ref imageClipQuality)) { DefaultImageClipQuality = imageClipQuality; } int mouseMoveSendingInterval = Consts.DEFAULT_MOUSE_MOVE_SEND_INTERVAL; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_MOUSE_MOVE_SEND_INTERVAL, 0, int.MaxValue, ref mouseMoveSendingInterval)) { MouseMoveSendInterval = mouseMoveSendingInterval; } } Raiser.CallDelegatorBySync(EventConfigurationChanged, new object[] { null, EventArgs.Empty }); }
private void EndReceive(IAsyncResult result) { try { int len = this.mNetworkStream.EndRead(result); if (len > 0) { if (mReceiveBuffer[0].Equals((byte)1)) { // alacsony szintű visszajelzés lock (mSentTCPMessages) { if (mSentTCPMessages.Count > 0) { mSentTCPMessages.RemoveAt(0); } } StartReceive(); } else if (mReceiveBuffer[0].Equals((byte)0)) { TerraGrafMessageBase message = this.mMessageFormatter.Read(this.mNetworkStream); if (message.MessageType == MessageTypeEnum.Tcp) { // alacsony szintű visszajelzés küldése lock (mSentTCPMessages) { if (mConnected) { MessageLowLevelAcknowledge msg = new MessageLowLevelAcknowledge(); AddMessageTask(new MessageTask(msg)); } } } Raiser.CallDelegatorBySync(MessageArrived, new object[] { this, new MessageArrivedEventArgs(message) }); StartReceive(); } else { if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("NETWORK_CONNECTION: invalid start code in network stream. StreamId: {0}", this.mNetworkStream.Id)); } this.mNetworkStream.Close(); HandleDisconnection(); } } else { if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("Id: {0}, zero bytes received - socket disconnected.", mNetworkStream.Id)); } HandleDisconnection(); } } catch (Exception ex) { if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("Id: {0}, {1}, {2}", mNetworkStream.Id, ex.GetType().Name, ex.Message)); } HandleDisconnection(); } }
private void Send(object state) { if (mConnected) { MessageTask task = null; Queue <MessageTask> selectedQueue = null; foreach (Queue <MessageTask> queue in this.mMessageQueues) { lock (queue) { if (queue.Count > 0) { selectedQueue = queue; task = queue.Peek(); break; } } } if (task != null) { Stopwatch watch = Stopwatch.StartNew(); try { if (task.Message.MessageCode == MessageCodeEnum.LowLevelTcpAcknowledge) { // alacsonyszintű visszajelzés this.mNetworkStream.Write(LOW_LEVEL_RESPONSE_BYTE, 0, LOW_LEVEL_RESPONSE_BYTE.Length); } else { if (task.Message.MessageType == MessageTypeEnum.Tcp) { // a TCP üzenetekről kérek alacsony szintű visszajelzést lock (mSentTCPMessages) { mSentTCPMessages.Add(task); } } this.mMessageFormatter.Write(this.mNetworkStream, task.Message); } watch.Stop(); if (LOGGER.IsDebugEnabled) { LOGGER.Debug(string.Format("NETWORK_CONNNECTION, Id: {0}, Message sent. MessageId: {1}", this.mNetworkStream.Id.ToString(), task.Message.MessageId.ToString())); } mReplyTime = watch.ElapsedMilliseconds; lock (selectedQueue) { selectedQueue.Dequeue(); } // sikeres küldés Raiser.CallDelegatorBySync(MessageSendAfter, new object[] { this, new MessageSendEventArgs(task, false) }); lock (LOCK_OBJECT) { mTotalMessagesToSend--; if (mTotalMessagesToSend > 0) { THREADPOOL.QueueUserWorkItem(new WaitCallback(Send)); } } } catch (ObjectDisposedException ex) { // hálózati hiba (lezárt stream) if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("Id: {0}, {1}, {2}", mNetworkStream.Id, ex.GetType().Name, ex.Message)); } HandleDisconnection(); } catch (IOException ex) { // hálózati hiba if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("Id: {0}, {1}, {2}", mNetworkStream.Id, ex.GetType().Name, ex.Message)); } this.mNetworkStream.Dispose(); HandleDisconnection(); } catch (InvalidOperationException ex) { // hálózati hiba if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("Id: {0}, {1}, {2}", mNetworkStream.Id, ex.GetType().Name, ex.Message)); } this.mNetworkStream.Dispose(); HandleDisconnection(); } catch (Exception ex) { // ismeretlen hiba if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("Id: {0}, {1}, {2}", mNetworkStream.Id, ex.GetType().Name, ex.Message)); } lock (selectedQueue) { selectedQueue.Dequeue(); } this.mNetworkStream.Dispose(); HandleDisconnection(); } finally { if (watch.IsRunning) { watch.Stop(); } } } } }