예제 #1
0
        public GameSyncer(LimeNode node, string host, int port, string nickname, int netUps, int bodyUps,
                          bool debug = false)
        {
            this.node     = node;
            this.host     = host;
            this.port     = port;
            this.nickname = nickname;
            this.netUps   = netUps;
            this.bodyUps  = bodyUps;
#if DEBUG
            this.debug = debug;
#endif

            this.node.configureGlint();
            this.node.initialize();

            incomingBodyUpdates = new ConcurrentQueue <BodyUpdate>();
            outgoingGameUpdates = new ConcurrentQueue <GameUpdateMessage>();

            // wire events
            this.node.onPeerConnected    += onPeerConnected;
            this.node.onPeerDisconnected += onPeerDisconnected;
            this.node.onMessage          += onMessage;
            this.node.onUpdate           += onUpdate;

            registerHandlers();
        }
예제 #2
0
        public static void configureGlint(this LimeNode node)
        {
            // register lime logging handler
            node.onLog += (level, s) => {
                switch (level)
                {
                case Verbosity.Trace:
                    Global.log.trace(s);
                    break;

                case Verbosity.Warning:
                    Global.log.warn(s);
                    break;

                case Verbosity.Error:
                    Global.log.err(s);
                    break;
                }
            };
        }