public void Configuration(IAppBuilder app) { // Weitere Informationen zum Konfigurieren Ihrer Anwendung finden Sie unter https://go.microsoft.com/fwlink/?LinkID=316888. // NuGet Microsoft.AspNet.SignalR // Microsoft.AspNet.SignalR.SelfHost // Microsoft.EntityFrameworkCore.Sqlite app.MapSignalR(); ChatServerContext.Init(); }
// Put: api/Messages public void Put([FromBody] MessageStateModification messageState) { var message = ChatServerContext.Messages.FirstOrDefault(m => m.MessageGuid == messageState.MessageGuid); if (message != null) { message.State = messageState.MessageState; hubContext.Clients.Client(message.From.ConnectionGuid).ReceiveMessageStateModification(messageState); } ChatServerContext.SaveChanges(); }
// POST: api/Register public User Post([FromBody] string userName) { User output = new User { Nickname = userName, UserGuid = Guid.NewGuid().ToString() }; ChatServerContext.Users.Add(output); ChatServerContext.SaveChanges(); return(output); }
public Server(string identifier, ChatServerContext context) : base(identifier, context) { if (Hostname == null) { Hostname = Context.Config.Get("Chat.Protocols.IRC", "Hostname", "irc.flash.moe"); } Log = new Logger($"IRC Server ({Identifier})"); short bindPort = Context.Config.Get<short>("Chat.Protocols.IRC", "Port", 6667); Listener = new TcpListener(IPAddress.Any, bindPort); Log.Write(LogSeverity.Info, "Creating IRC server on port {0}.", bindPort.ToString()); }
// POST: api/Login public void Post([FromBody] User user) { var searchUser = ChatServerContext.GetUser(user.UserGuid); if (searchUser == null) { ChatServerContext.Users.Add(user); ChatServerContext.SaveChanges(); } IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext <ChatHub>(); hubContext.Clients.Client(user.ConnectionGuid).Hello(); }
public Server(string identifier, ChatServerContext context) : base(identifier, context) { Log = new Logger($"Sock Chat Server ({Identifier})"); short bindPort = Context.Config.Get<short>("Chat.Protocols.SockChat", "Port", 6770); Log.Write(LogSeverity.Info, "Creating SockLegacy server on port {0}.", bindPort.ToString()); Socket = new WebSocketServer(bindPort); Socket.AddWebSocketService(Endpoint, () => { return new Service(Context); }); }
public override Task OnConnected() { var connectionGuid = Context.ConnectionId; var userGuid = Context.Headers.Get(Constants.UserGuid); var searchUser = ChatServerContext.GetUser(userGuid); if (searchUser != null) { searchUser.ConnectionGuid = connectionGuid; ChatServerContext.SaveChanges(); } return(base.OnConnected()); }
// POST: api/Messages public void Post([FromBody] Message message) { DataContext.Instance.Context.Messages.Add(message); ChatServerContext.Messages.Add(message); ChatServerContext.SaveChanges(); var messageState = new MessageStateModification { MessageGuid = message.MessageGuid, MessageState = MessageState.OnServer }; hubContext.Clients.Client(message.From.ConnectionGuid).ReceiveMessageStateModification(messageState); var conGuid = ChatServerContext.Users.FirstOrDefault(u => u.UserGuid == message.ToGuid)?.ConnectionGuid; if (conGuid != null) { hubContext.Clients.Client(conGuid).ReceivePrivateMessage(message); } }
public Server(string identifier, ChatServerContext context) : base(identifier, context) { }
public ServerProtocol(string identifier, ChatServerContext context) { Identifier = identifier; Context = context; }
public Service(ChatServerContext context) : base() { ServerContext = context; AuthClient = new AuthClient(context.Config); }