Ejemplo n.º 1
0
        /// <summary>
        /// Performs plugin cleanup logic
        /// Remove your hooks and perform general cleanup here
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                AsynchronousSocketSender.Send("ServerShutdown: true");
                //unhook
                //dispose child objects
                //set large objects to null
                ServerApi.Hooks.ServerJoin.Deregister(this, OnServerJoin);
                ServerApi.Hooks.ServerLeave.Deregister(this, OnServerLeave);
                ServerApi.Hooks.ServerChat.Deregister(this, OnServerChat);
                ServerApi.Hooks.GamePostInitialize.Deregister(this, OnGamePostInitialize);
                ServerApi.Hooks.ServerBroadcast.Deregister(this, OnServerBroadcast);


                try {
                    if (socketThread != null)
                    {
                        socketThread.Abort();
                    }
                } catch (Exception ex) {
                }
                AsynchronousSocketSender.Stop();
            }
            base.Dispose(disposing);
        }
Ejemplo n.º 2
0
 void OnServerChat(ServerChatEventArgs args)
 {
     if (args != null)
     {
         if (TShockAPI.TShock.Players[args.Who] != null)
         {
             AsynchronousSocketSender.Send($"ServerChat: {TShockAPI.TShock.Players[args.Who].Name}\n{args.Text}");
         }
     }
 }
Ejemplo n.º 3
0
 void OnServerLeave(LeaveEventArgs args)
 {
     if (args != null)
     {
         if (TShockAPI.TShock.Players[args.Who] != null)
         {
             AsynchronousSocketSender.Send($"ServerLeave: {TShockAPI.TShock.Players[args.Who].Name}\n{TShockAPI.TShock.Players[args.Who].IP}");
         }
     }
 }
Ejemplo n.º 4
0
 void OnServerJoin(JoinEventArgs args)
 {
     if (args != null)
     {
         if (TShockAPI.TShock.Players[args.Who] != null)
         {
             Console.WriteLine($"ServerJoin: {TShockAPI.TShock.Players[args.Who].Name}");
             AsynchronousSocketSender.Send($"ServerJoin: {TShockAPI.TShock.Players[args.Who].Name}\n{TShockAPI.TShock.Players[args.Who].IP}");
         }
     }
 }
Ejemplo n.º 5
0
 private void OnServerBroadcast(ServerBroadcastEventArgs args)
 {
     if (args != null)
     {
         if (args.Message == null)
         {
             return;
         }
         if (args.Color == null)
         {
             return;
         }
         AsynchronousSocketSender.Send($"ServerBroadcast: {args.Message}\n{args.Color.ToString()}");
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Performs plugin initialization logic.
        /// Add your hooks, config file read/writes, etc here
        /// </summary>
        public override void Initialize() //First method TShock runs when the plugin is loaded
        {
            instance = this;
            ServerApi.Hooks.ServerJoin.Register(this, OnServerJoin);
            ServerApi.Hooks.ServerLeave.Register(this, OnServerLeave);
            ServerApi.Hooks.ServerChat.Register(this, OnServerChat);
            ServerApi.Hooks.GamePostInitialize.Register(this, OnGamePostInitialize);
            ServerApi.Hooks.ServerBroadcast.Register(this, OnServerBroadcast);

            //TShockAPI.Utils.Instance.
            socketThread = new Thread(AsynchronousSocketListener.StartListening);
            socketThread.Start();
            senderThread = new Thread(AsynchronousSocketSender.StartLoop);
            senderThread.Start();
            AsynchronousSocketSender.Send("ServerInit: true");
            // Console.WriteLine("I'm not stuck :3");
        }
Ejemplo n.º 7
0
 private void OnGamePostInitialize(EventArgs args)
 {
     AsynchronousSocketSender.Send("GamePostInitialize: true");
 }