Пример #1
0
        private void OnLoginRequest(Message msg)
        {
            var req = (LoginRequest)msg.Body;

            this.name    = req.Name;
            this.actorId = this.scene.AllocateCube(this.name);

            if (this.actorId > 0)
            {
                logger.Info("Login succeeded: {0}, ObjectId: {1}", this.name, this.actorId);

                var fbb  = new FlatBufferBuilder(1024);
                var oRes = LoginResponse.CreateLoginResponse(fbb, this.actorId);
                LoginResponse.FinishLoginResponseBuffer(fbb, oRes);

                WriteBytes(FlatBufferExtensions.ToProtocolMessage(fbb, ServerMessageIds.LoginResponse));

                foreach (var bytes in this.scene.GetSceneData())
                {
                    WriteBytes(bytes);
                }
            }
            else
            {
                logger.Info("Login failed.");
            }
        }