Ejemplo n.º 1
0
 public void Scribble(String sender, byte[] img, int height)
 {
     if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLogin.Ready)
     {
         ServerCore.Linker.SendPacket(LeafOutbound.LeafScribbleLeaf(ServerCore.Linker, this.Ident, sender, height, img));
     }
 }
Ejemplo n.º 2
0
 public void SendEmote(String sender, String text)
 {
     if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLogin.Ready)
     {
         ServerCore.Linker.SendPacket(LeafOutbound.LeafEmoteTextToLeaf(ServerCore.Linker, this.Ident, sender, text));
     }
 }
Ejemplo n.º 3
0
 public void Print(iconnect.ILevel level, String text)
 {
     if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLogin.Ready)
     {
         ServerCore.Linker.SendPacket(LeafOutbound.LeafPrintLevel(ServerCore.Linker, this.Ident, level, text));
     }
 }
Ejemplo n.º 4
0
 public void Print(ushort vroom, String text)
 {
     if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLogin.Ready)
     {
         ServerCore.Linker.SendPacket(LeafOutbound.LeafPrintVroom(ServerCore.Linker, this.Ident, vroom, text));
     }
 }
Ejemplo n.º 5
0
 public void RestoreAvatar()
 {
     if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
     {
         ServerCore.Linker.SendPacket(LeafOutbound.LeafIUser(ServerCore.Linker,
                                                             this, "restoreavatar", String.Empty));
     }
 }
Ejemplo n.º 6
0
 public void Disconnect()
 {
     if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
     {
         ServerCore.Linker.SendPacket(LeafOutbound.LeafIUser(ServerCore.Linker,
                                                             this, "disconnect", String.Empty));
     }
 }
Ejemplo n.º 7
0
 public void Print(object text)
 {
     if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
     {
         ServerCore.Linker.SendPacket(LeafOutbound.LeafIUser(ServerCore.Linker,
                                                             this, "print", text.ToString()));
     }
 }
Ejemplo n.º 8
0
 public void Nudge(String sender)
 {
     if (this.CustomClient)
     {
         if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
         {
             ServerCore.Linker.SendPacket(LeafOutbound.LeafNudge(ServerCore.Linker, this, sender));
         }
     }
 }
Ejemplo n.º 9
0
 public void URL(String address, String text)
 {
     if (!String.IsNullOrEmpty(address) && !String.IsNullOrEmpty(text))
     {
         if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
         {
             ServerCore.Linker.SendPacket(LeafOutbound.LeafIUser(ServerCore.Linker,
                                                                 this, "url", address, text));
         }
     }
 }
Ejemplo n.º 10
0
 public void Topic(String text)
 {
     if (text != null)
     {
         if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
         {
             ServerCore.Linker.SendPacket(LeafOutbound.LeafIUser(ServerCore.Linker,
                                                                 this, "topic", text));
         }
     }
 }
Ejemplo n.º 11
0
 public void PM(String sender, String text)
 {
     if (!String.IsNullOrEmpty(sender) && !String.IsNullOrEmpty(text))
     {
         if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
         {
             ServerCore.Linker.SendPacket(LeafOutbound.LeafIUser(ServerCore.Linker,
                                                                 this, "pm", sender, text));
         }
     }
 }
Ejemplo n.º 12
0
 public void SendEmote(String text)
 {
     if (!String.IsNullOrEmpty(text))
     {
         if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
         {
             ServerCore.Linker.SendPacket(LeafOutbound.LeafIUser(ServerCore.Linker,
                                                                 this, "sendemote", text));
         }
     }
 }
Ejemplo n.º 13
0
 public void Redirect(String hashlink)
 {
     if (!String.IsNullOrEmpty(hashlink))
     {
         if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
         {
             ServerCore.Linker.SendPacket(LeafOutbound.LeafIUser(ServerCore.Linker,
                                                                 this, "redirect", hashlink));
         }
     }
 }
Ejemplo n.º 14
0
 public void BinaryWrite(byte[] data)
 {
     if (data != null)
     {
         if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
         {
             ServerCore.Linker.SendPacket(LeafOutbound.LeafIUserBin(ServerCore.Linker,
                                                                    this, "binary", data));
         }
     }
 }
Ejemplo n.º 15
0
        public void Service(ulong time)
        {
            if (!this.Busy)
            {
                return;
            }

            if (this.LoginPhase == LinkLogin.Sleeping)
            {
                if (time > (this.Time + 30000))
                {
                    this.LoginPhase    = LinkLogin.Connecting;
                    this.Time          = time;
                    this.Sock          = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    this.Sock.Blocking = false;

                    try
                    {
                        this.Sock.Connect(new IPEndPoint(this.ExternalIP, this.Port));
                    }
                    catch { }
                }

                return;
            }

            if (this.LoginPhase == LinkLogin.Connecting)
            {
                if (this.Sock.Poll(0, SelectMode.SelectWrite))
                {
                    this.LoginPhase = LinkLogin.AwaitingAck;
                    this.SendPacket(LeafOutbound.LeafLogin());
                    this.Time     = time;
                    this.LastPong = time;
                }
                else if (time > (this.Time + 15000))
                {
                    this.KillSocket();

                    if (this.CanReconnect)
                    {
                        this.Time       = time;
                        this.LoginPhase = LinkLogin.Sleeping;
                    }
                    else
                    {
                        this.Busy = false;
                    }

                    Events.LinkError(LinkError.UnableToConnect);
                }
            }
            else
            {
                core.LinkHub.LinkPacket packet = null;

                while ((packet = this.NextReceivedPacket) != null && this.SocketConnected)
                {
                    try
                    {
                        LeafProcessor.Eval(this, packet.Msg, packet.Packet, time);
                    }
                    catch (Exception e)
                    {
                        this.KillSocket();
                        bool was_linked = this.LoginPhase == LinkLogin.Ready;

                        if (this.CanReconnect)
                        {
                            this.Time       = time;
                            this.LoginPhase = LinkLogin.Sleeping;
                        }
                        else
                        {
                            this.Busy = false;
                        }

                        Events.LinkError(LinkError.BadProtocol);
                        ServerCore.Log("packet read fail from hub " + packet.Msg, e);

                        if (was_linked)
                        {
                            this.ClearUserlist();
                        }

                        Events.Unlinked();
                        return;
                    }
                }

                this.SendReceive();

                if (!this.SocketConnected)
                {
                    this.KillSocket();
                    bool unlink_fire = this.LoginPhase == LinkLogin.Ready;

                    if (this.CanReconnect)
                    {
                        this.Time       = time;
                        this.LoginPhase = LinkLogin.Sleeping;
                    }
                    else
                    {
                        this.Busy = false;
                    }

                    Events.LinkError(LinkError.RemoteDisconnect);

                    if (unlink_fire)
                    {
                        this.ClearUserlist();
                        Events.Unlinked();
                    }
                }
                else if (this.LoginPhase == LinkLogin.AwaitingAck)
                {
                    if (time > (this.Time + 60000))
                    {
                        this.KillSocket();

                        if (this.CanReconnect)
                        {
                            this.Time       = time;
                            this.LoginPhase = LinkLogin.Sleeping;
                        }
                        else
                        {
                            this.Busy = false;
                        }

                        Events.LinkError(LinkError.HandshakeTimeout);
                    }
                }
                else if (this.LoginPhase == LinkLogin.Ready)
                {
                    if (time > (this.Time + 60000))
                    {
                        this.Time = time;
                        this.SendPacket(LeafOutbound.LeafPing());
                    }

                    if (time > (this.LastPong + 240000))
                    {
                        this.KillSocket();

                        if (this.CanReconnect)
                        {
                            this.Time       = time;
                            this.LoginPhase = LinkLogin.Sleeping;
                        }
                        else
                        {
                            this.Busy = false;
                        }

                        Events.LinkError(LinkError.PingTimeout);
                        this.ClearUserlist();
                        Events.Unlinked();
                    }
                }
            }
        }