public Listener( int port, int timeout, bool useIPv6, PropertyChangedWithValueEventHandler propertyChangedHandler = null, MessageReceivedEventHandler messageReceivedEventHandler = null ) { Port = port; Timeout = timeout; if (propertyChangedHandler != null) { _propertyChangedHandler = propertyChangedHandler; this.PropertyChangedWithValue += propertyChangedHandler; } if (messageReceivedEventHandler != null) { _messageReceivedEventHandler = messageReceivedEventHandler; this.MessageReceived += messageReceivedEventHandler; } _listener = new TcpListenerEx( (useIPv6 ? IPAddress.IPv6Any : IPAddress.Any), Port ); if (useIPv6) { _listener.Server.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, 0); } _worker = CreateWorker(); }
public Talker( string host, int port, int timeout, PropertyChangedWithValueEventHandler propertyChangedWithValue = null ) { Host = host; Port = port; Timeout = timeout; if (propertyChangedWithValue != null) { _propertyChangedWithValue = propertyChangedWithValue; this.PropertyChangedWithValue += propertyChangedWithValue; } _client = new TcpClient(Host, Port); _ns = _client.GetStream(); if (_ns.CanTimeout) { _ns.ReadTimeout = Timeout * 1000; _ns.WriteTimeout = Timeout * 1000; } _worker = CreateWorker(); this.NotifyPropertyChanged("Connected", true); }
public KingdomClanVMExtensionVM(Action <TaleWorlds.CampaignSystem.Election.KingdomDecision> forceDecide) : base(forceDecide) { Events.FiefGranted.AddNonSerializedListener(this, RefreshCanGrantFief); _grantFiefInterface = new GrantFiefInterface(); GrantFiefActionName = new TextObject("{=LpoyhORp}Grant Fief").ToString(); GrantFiefExplanationText = new TextObject("{=98hwXUTp}Grant fiefs to clans in your kingdom").ToString(); DonateGoldActionName = new TextObject("{=Gzq6VHPt}Donate Gold").ToString(); DonateGoldExplanationText = new TextObject("{=7QvXkcxH}Donate gold to clans in your kingdom").ToString(); UsurpThroneActionName = new TextObject("{=N7goPgiq}Usurp Throne").ToString(); _usurpThroneExplanationText = string.Empty; PropertyChangedWithValue += new PropertyChangedWithValueEventHandler(OnPropertyChangedWithValue); RefreshCanGrantFief(); RefreshCanUsurpThrone(); }