Пример #1
0
 public RoomService(IIdentityProvider identityProvider, ICommandStore commandService, IHttpService httpService)
 {
     _auth           = new EmailAuthenticationProvider(identityProvider.Username, identityProvider.Password);
     _commandService = commandService;
     _httpService    = httpService;
     _activeRooms    = new Dictionary <int, RoomWatcher <DefaultWebSocket> >();
 }
Пример #2
0
    private static async Task Demo()
    {
        // Fetch your account's credentials from somewhere.
        var auth = new EmailAuthenticationProvider("", "");

        // Create an instance of the ActionScheduler. This will
        // allow us to execute chat actions like: posting messages,
        // kicking users, moving messages, etc.
        using (var actionScheduler = new ActionScheduler(auth, roomUrl))
        {
            // Create an instance of the RoomWatcher class. Here we
            // specify (via the type parameter) what WebSocket implementation
            // we'd like to use. This class allows you to subscribe to chat events.
            using (var roomWatcher = new RoomWatcher <DefaultWebSocket>(auth, roomUrl))
            {
                // Subscribe to the UserMentioned event.
                roomWatcher.AddUserMentionedEventHandler(async m =>
                {
                    await actionScheduler.CreateReplyAsync("hello!", m.MessageId);

                    /// Do stuff ...
                });

                // Besides being able to subscribe to the default events,
                // you can also create (and listen to) your own. Your class must
                // implement the ChatEventDataProcessor class, you can also
                // optionally implement IChatEventHandler or IChatEventHandler<T>.
                var customEventHanlder = new AllData();

                // Add a very basic handler.
                customEventHanlder.OnEvent += data => Console.WriteLine(data);

                // Add our custom event handler so we can
                // begin processing the incoming event data.
                roomWatcher.EventRouter.AddProcessor(customEventHanlder);

                // Post a simple message.
                var messageId = await actionScheduler.CreateMessageAsync("Hello world.");

                while (Console.ReadKey(true).Key != ConsoleKey.Q)
                {
                }
            }
        }
    }
Пример #3
0
 public RoomService(IIdentityProvider identityProvider, ICommandService commandService)
 {
     this.auth           = new EmailAuthenticationProvider(identityProvider.Username, identityProvider.Password);
     this.commandService = commandService;
     this.activeRooms    = new Dictionary <int, RoomWatcher <DefaultWebSocket> >();
 }
 public RoomService(string username, string password)
 {
     this.auth        = new EmailAuthenticationProvider(username, password);
     this.activeRooms = new Dictionary <int, RoomWatcher <DefaultWebSocket> >();
 }