コード例 #1
0
 public TcpClient(IClientOptions options = null)
 {
     Options     = options ?? new ClientOptions();
     _throttlers =
         new Throttlers(this, Options.ThrottlingPeriod, Options.WhisperThrottlingPeriod)
     {
         TokenSource = _tokenSource
     };
     InitializeClient();
 }
コード例 #2
0
        internal void Connect()
        {
            Console.WriteLine("Connecting...");

            // Client Connect
            client = new TwitchClient(linkage);
            client.Initialize(botCred, Credentials.ChannelName);
            breakPedal = new Throttlers(linkage, TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(60));

            while (commandSwitch < 0 || commandSwitch > 3)
            {
                commandSwitch = Convert.ToInt16(WBF.gameQuestion());
            }

            masterList = WBF.UserTake(masterList);

            if (commandSwitch == 1 || commandSwitch == 2)
            {
                barracks = WBF.SoldierTake(barracks);
            }
            else if (commandSwitch == 3)
            {
                npc = WBF.NPC_Take(npc);
            }
            else
            {
                ;
            }

            client.OnConnected     += On_Connected;
            client.OnJoinedChannel += On_JoinedChennel;

            client.OnUserJoined += On_UserJoined;
            client.OnUserLeft   += On_UserLeft;

            client.AddChatCommandIdentifier('!');
            client.OnChatCommandReceived += On_CommandReceived;
            client.AddWhisperCommandIdentifier('!');
            client.OnWhisperCommandReceived += On_WhisperCommandReceived;

            client.OnBeingHosted      += On_BeingHosted;
            client.OnRaidNotification += On_BeingRaided;

            client.OnGiftedSubscription += On_GiftedSub;
            client.OnNewSubscriber      += On_NewSub;
            client.OnReSubscriber       += On_ReSub;

            client.OnMessageThrottled += On_MessageThrottle;
            client.OnWhisperThrottled += On_WhisperThrottle;

            client.Connect();

            upTimer();
        }
コード例 #3
0
        public WebSocketClient(IClientOptions options = null)
        {
            Options = options ?? new ClientOptions();

            switch (Options.ClientType)
            {
            case ClientType.Chat:
                Url = Options.UseSsl ? "wss://irc-ws.chat.twitch.tv:443" : "ws://irc-ws.chat.twitch.tv:80";
                break;

            case ClientType.PubSub:
                Url = Options.UseSsl ? "wss://pubsub-edge.twitch.tv:443" : "ws://pubsub-edge.twitch.tv:80";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            _throttlers = new Throttlers(this, Options.ThrottlingPeriod, Options.WhisperThrottlingPeriod)
            {
                TokenSource = _tokenSource
            };
        }