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> >(); }
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) { } } } }
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> >(); }