static void Authenticate(Agent sender, string[] msg) { if (sender.Authenticated == false) { if (Database.Authenticate(msg[1], msg[2])) { Character c = Database.GetChar(msg[1]); Agent a = VisitorBase.GetVisitors().Find(new Predicate <Agent>(x => x.Name == c.Name)); if (a != null) { Logger.LogIt(typeof(Lobby), "User " + sender.Name + " already on server"); sender.Send("000_1"); return; } sender.Authenticated = true; sender.Name = c.Name; Logger.LogIt(typeof(Lobby), "User " + c.Name + " Authenticated"); sender.Send("000_0_" + c.Name); return; } else { Logger.LogIt(typeof(Lobby), "User " + sender.Name + " Auth failed"); sender.Send("000_1"); } } }
public static void Comm(Agent sender, string[] msg) { foreach (var a in VisitorBase.GetVisitors()) { a.Send("030_" + sender.Name + ": " + msg[1]); } }
static void DrawInfo() { Console.WriteLine("Visitors: " + VisitorBase.GetVisitors().Count); foreach (var v in VisitorBase.GetVisitors()) { Console.WriteLine("Visitor: " + v.Name); } }
void ClientAccept(Socket Listener) { while (true) { try { VisitorBase.NewVisitor(Listener.Accept()); } catch (Exception e) { Logger.LogIt(typeof(Server), "Client accept error:" + e.Message); break; } } }
public static void SendInfo_SPs(Agent sender = null) { foreach (var sp in SpacePorts.Keys) { string tosend = CommandBuilder.Build(new string[] { "006", sp.ID.ToString(), sp.rocket.ID.ToString(), sp.rocket.PSGR == null ? "0" : "1" }); if (sender != null) { sender.Send(tosend); } else { var authVisitors = VisitorBase.GetVisitors().FindAll(new Predicate <Agent>(x => x.Authenticated)); authVisitors.ForEach(x => x.Send(tosend)); } } }
public static void OnError(Agent agent) { Lobby.scene.DisconnectPlayer(agent, true); agent.RSite?.Disconnect(agent); VisitorBase.DeleteVisitor(agent); }