public static Offset <ReturnStatus> CreateReturnStatus(FlatBufferBuilder builder, MsgStatus status = MsgStatus.S_Unknown) { builder.StartObject(1); ReturnStatus.AddStatus(builder, status); return(ReturnStatus.EndReturnStatus(builder)); }
// This will be called whenever the list changes. private void ServerEvent(object sender, SampleEventArgs e) { Console.WriteLine("-> ServerEvent incoming Message"); // Verify the message contents are trustworthy. try { ByteBuffer byteBuffer = new ByteBuffer(e.Data); var message = NetMsg.MessageRoot.GetRootAsMessageRoot(byteBuffer); // read Console.WriteLine("-> ServerEvent incoming Message.DataType:" + message.DataType); switch (message.DataType) { case NetMsg.Data.ReturnStatus: NetMsg.ReturnStatus status = new NetMsg.ReturnStatus(); status = message.GetData <NetMsg.ReturnStatus>(status); switch (status.Status) { case NetMsg.MsgStatus.S_LoginSuccess: _SocketServerManager.Client.HostInfo.isLoggedIn = true; break; } break; case NetMsg.Data.Chatmessage: NetMsg.Chatmessage msg = new NetMsg.Chatmessage(); msg = message.GetData <NetMsg.Chatmessage>(msg); Console.WriteLine("NetMsg.Data.Chatmessage:" + msg.Text); break; case NetMsg.Data.Scene: XFBType.Scene scene = new XFBType.Scene(); scene = message.GetData <XFBType.Scene>(scene); Console.WriteLine("NetMsg.Data.Scene:" + scene.Sceneid); break; case NetMsg.Data.Entity: Entity ent = new Entity(); ent = message.GetData <Entity>(ent); Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Normal, new Action(() => { var model = this.DataContext as SocketServerToolModel; var entityExists = model.SceneItems.Where(x => x.Entity.EntityID == ent.EntityID); if (entityExists.Any()) { var existingEntity = entityExists.First(); for (int i = 0; i < ent.ComponentsLength; i++) { var comp = ent.GetComponents(i); Console.WriteLine("NetMsg.Data.Entity -> ComponentType:" + comp.CompType); if (comp.CompType == UComponent.BodyComponent) { XFBType.BodyComponent fbBody = new XFBType.BodyComponent(); comp.GetComp(fbBody); var body = existingEntity.Entity.GetComponentX <BodyComponent>() as BodyComponent; body.FB_BodyComponent.Location = new Interface.Scene.Services.Vector3() { X = fbBody.Position.X, Y = fbBody.Position.Y, Z = fbBody.Position.Z }; body.FB_BodyComponent.Rotation = new Interface.Scene.Services.Quaternion() { W = fbBody.Rotation.W, X = fbBody.Rotation.X, Y = fbBody.Rotation.Y, Z = fbBody.Rotation.Z }; body.FB_BodyComponent.Scale = new Interface.Scene.Services.Vector3() { X = fbBody.Scale.X, Y = fbBody.Scale.Y, Z = fbBody.Scale.Z }; } } } else // new entity { var newEntity = new EntityX() { EntityID = ent.EntityID, NetID = message.Netid, SceneID = message.Scene }; for (int i = 0; i < ent.ComponentsLength; i++) { var comp = ent.GetComponents(i); Console.WriteLine("NetMsg.Data.Entity -> ComponentType:" + comp.CompType); if (comp.CompType == UComponent.BodyComponent) { XFBType.BodyComponent fbBody = new XFBType.BodyComponent(); comp.GetComp(fbBody); var body = new BodyComponent() { Parent = newEntity }; body.FB_BodyComponent.Location = new Interface.Scene.Services.Vector3() { X = fbBody.Position.X, Y = fbBody.Position.Y, Z = fbBody.Position.Z }; body.FB_BodyComponent.Rotation = new Interface.Scene.Services.Quaternion() { W = fbBody.Rotation.W, X = fbBody.Rotation.X, Y = fbBody.Rotation.Y, Z = fbBody.Rotation.Z }; body.FB_BodyComponent.Scale = new Interface.Scene.Services.Vector3() { X = fbBody.Scale.X, Y = fbBody.Scale.Y, Z = fbBody.Scale.Z }; newEntity.Components.Add(body); } } model.SceneItems.Add(new SourceItem() { Entity = newEntity }); } })); break; } } catch (Exception ex) { Console.WriteLine(e.Data); } }
public static ReturnStatus GetRootAsReturnStatus(ByteBuffer _bb, ReturnStatus obj) { return(obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }