예제 #1
0
 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");
         }
     }
 }
예제 #2
0
 public static void Comm(Agent sender, string[] msg)
 {
     foreach (var a in VisitorBase.GetVisitors())
     {
         a.Send("030_" + sender.Name + ": " + msg[1]);
     }
 }
예제 #3
0
 static void DrawInfo()
 {
     Console.WriteLine("Visitors: " + VisitorBase.GetVisitors().Count);
     foreach (var v in VisitorBase.GetVisitors())
     {
         Console.WriteLine("Visitor: " + v.Name);
     }
 }
예제 #4
0
 void ClientAccept(Socket Listener)
 {
     while (true)
     {
         try
         {
             VisitorBase.NewVisitor(Listener.Accept());
         }
         catch (Exception e)
         {
             Logger.LogIt(typeof(Server), "Client accept error:" + e.Message);
             break;
         }
     }
 }
예제 #5
0
 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));
         }
     }
 }
예제 #6
0
 public static void OnError(Agent agent)
 {
     Lobby.scene.DisconnectPlayer(agent, true);
     agent.RSite?.Disconnect(agent);
     VisitorBase.DeleteVisitor(agent);
 }