예제 #1
0
파일: Listener.cs 프로젝트: hnjm/cs-p2pChat
 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();
 }
예제 #2
0
 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();
 }
예제 #3
0
 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();
        }
예제 #5
0
 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);
 }