/// <summary> /// 服务端下发帧同步命令集 /// </summary> /// <param name="stream"></param> public void NotifySynOperations(MemoryStream stream) { MessageNotifySyncOperations res = MessageNotifySyncOperations.Parser.ParseFrom(stream); if (res.PlayerOperations.Count > 0) { List <Operation> opes = new List <Operation>(res.PlayerOperations); CommandManager.GetInstance().doCommand(opes); } }
void SyncOperationsPerFrame() { lock (OperationsList) { operationsStream.SetLength(0); operationsStream.Position = 0; ByteBuffer buffer; MessageNotifySyncOperations msg = new MessageNotifySyncOperations(); if (OperationsList.Count > 0) { msg.PlayerOperations.AddRange(OperationsList); } Google.Protobuf.MessageExtensions.WriteTo(msg, operationsStream); buffer = createByteBuffer((ushort)MSG_CS.NotifySyncOperations, operationsStream); foreach (var client in clientConnectionItems) { client.Value.BeginSend(buffer.ToBytes(), 0, buffer.ToBytes().Length, SocketFlags.None, null, null); } OperationsList.Clear(); } }