예제 #1
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameServer">The underlying game server.</param>
 /// <param name="reflection">Simplifies access to private code.</param>
 /// <param name="readFarmer">A method which reads farmer data from the given binary reader.</param>
 /// <param name="onProcessingMessage">A callback to raise when receiving a message. This receives the server instance, raw/parsed incoming message, and a callback to run the default logic.</param>
 /// <param name="onSendingMessage">A callback to raise when sending a message. This receives the server instance, outgoing connection, outgoing message, and a callback to run the default logic.</param>
 public SLidgrenServer(IGameServer gameServer, Reflector reflection, Func <BinaryReader, NetFarmerRoot> readFarmer, Action <SLidgrenServer, NetIncomingMessage, IncomingMessage, Action> onProcessingMessage, Action <SLidgrenServer, NetConnection, OutgoingMessage, Action> onSendingMessage)
     : base(gameServer)
 {
     this.ReadFarmer          = readFarmer;
     this.OnProcessingMessage = onProcessingMessage;
     this.OnSendingMessage    = onSendingMessage;
     this.Peers  = reflection.GetField <Bimap <long, NetConnection> >(this, "peers").GetValue();
     this.Server = reflection.GetField <NetServer>(this, "server");
 }
예제 #2
0
        private static bool Prefix_LidgrenServer_SendMessage(LidgrenServer __instance, NetConnection connection, OutgoingMessage message, Bimap <long, NetConnection> ___peers, IGameServer ___gameServer)
        {
            if (__instance is SLidgrenServer smapiServer)
            {
                smapiServer.SendMessage(connection, message);
                return(false);
            }

            return(true);
        }
예제 #3
0
        private static bool Prefix_LidgrenServer_ParseDataMessageFromClient(LidgrenServer __instance, NetIncomingMessage dataMsg, Bimap <long, NetConnection> ___peers, IGameServer ___gameServer)
        {
            if (__instance is SLidgrenServer smapiServer)
            {
                smapiServer.ParseDataMessageFromClient(dataMsg);
                return(false);
            }

            return(true);
        }