internal static OplogRequest CreateOpSetCheckRequestEntity(int cmdid, int key, int value) { KeyValPair.Builder rb = new KeyValPair.Builder(); rb.SetKey(key); rb.SetVal(value); byte[] byteUp = rb.Build().ToByteArray(); SKBuiltinBuffer_t.Builder skbb = new SKBuiltinBuffer_t.Builder(); skbb.SetBuffer(ByteString.CopyFrom(byteUp)); skbb.SetILen(byteUp.Length); SKBuiltinBuffer_t skbObj = skbb.Build(); CmdItem.Builder cib = new CmdItem.Builder(); cib.SetCmdBuf(skbObj); cib.SetCmdId(cmdid); CmdItem ciObj = cib.Build(); CmdList.Builder clb = new CmdList.Builder(); clb.SetCount(1); clb.AddList(ciObj); CmdList clObj = clb.Build(); OplogRequest.Builder nsrb = new OplogRequest.Builder(); nsrb.SetOplog(clObj); return(nsrb.Build()); }
internal static OplogRequest CreateExitChatroomRequestEntity(int cmdid, string chatroom, string self) { ExitChatroomObject.Builder rb = new ExitChatroomObject.Builder(); rb.SetChatroom(new SKBuiltinString_t.Builder().SetString(chatroom)); rb.SetUserName(new SKBuiltinString_t.Builder().SetString(self)); byte[] byteUp = rb.Build().ToByteArray(); SKBuiltinBuffer_t.Builder skbb = new SKBuiltinBuffer_t.Builder(); skbb.SetBuffer(ByteString.CopyFrom(byteUp)); skbb.SetILen(byteUp.Length); SKBuiltinBuffer_t skbObj = skbb.Build(); CmdItem.Builder cib = new CmdItem.Builder(); cib.SetCmdBuf(skbObj); cib.SetCmdId(cmdid); CmdItem ciObj = cib.Build(); CmdList.Builder clb = new CmdList.Builder(); clb.SetCount(1); clb.AddList(ciObj); CmdList clObj = clb.Build(); OplogRequest.Builder nsrb = new OplogRequest.Builder(); nsrb.SetOplog(clObj); return(nsrb.Build()); }
internal static OplogRequest CreateExitChatroomRequestEntity(int cmdid, string chatroom, string self) { ExitChatroomObject.Builder builder = new ExitChatroomObject.Builder(); builder.SetChatroom(new SKBuiltinString_t.Builder().SetString(chatroom)); builder.SetUserName(new SKBuiltinString_t.Builder().SetString(self)); byte[] array = builder.Build().ToByteArray(); SKBuiltinBuffer_t.Builder builder2 = new SKBuiltinBuffer_t.Builder(); builder2.SetBuffer(ByteString.CopyFrom(array)); builder2.SetILen(array.Length); SKBuiltinBuffer_t cmdBuf = builder2.Build(); CmdItem.Builder builder3 = new CmdItem.Builder(); builder3.SetCmdBuf(cmdBuf); builder3.SetCmdId(cmdid); CmdItem value = builder3.Build(); CmdList.Builder builder4 = new CmdList.Builder(); builder4.SetCount(1); builder4.AddList(value); CmdList oplog = builder4.Build(); OplogRequest.Builder builder5 = new OplogRequest.Builder(); builder5.SetOplog(oplog); return(builder5.Build()); }
internal static OplogRequest CreateOpSetCheckRequestEntity(int cmdid, int key, int value) { KeyValPair.Builder builder = new KeyValPair.Builder(); builder.SetKey(key); builder.SetVal(value); byte[] array = builder.Build().ToByteArray(); SKBuiltinBuffer_t.Builder builder2 = new SKBuiltinBuffer_t.Builder(); builder2.SetBuffer(ByteString.CopyFrom(array)); builder2.SetILen(array.Length); SKBuiltinBuffer_t cmdBuf = builder2.Build(); CmdItem.Builder builder3 = new CmdItem.Builder(); builder3.SetCmdBuf(cmdBuf); builder3.SetCmdId(cmdid); CmdItem value2 = builder3.Build(); CmdList.Builder builder4 = new CmdList.Builder(); builder4.SetCount(1); builder4.AddList(value2); CmdList oplog = builder4.Build(); OplogRequest.Builder builder5 = new OplogRequest.Builder(); builder5.SetOplog(oplog); return(builder5.Build()); }
public static NewSyncRequest ModifyProfile(string nickName, byte[] keyBuffer) { UserProfile.Builder upb = new UserProfile.Builder(); upb.SetBitFlag(2); upb.SetUserName(new SKBuiltinString_t.Builder().SetString("")); upb.SetNickName(new SKBuiltinString_t.Builder().SetString(nickName)); upb.SetBindUin(0); upb.SetBindEmail(new SKBuiltinString_t.Builder().SetString("")); upb.SetBindMobile(new SKBuiltinString_t.Builder().SetString("")); upb.SetStatus(0); upb.SetImgLen(0); upb.SetImgBuf(Google.ProtocolBuffers.ByteString.CopyFrom("", Encoding.Default)); upb.SetSex(0); upb.SetProvince(""); upb.SetCity(""); upb.SetSignature(""); upb.SetPersonalCard(1); upb.SetPluginFlag(0); upb.SetPluginSwitch(0); upb.SetAlias(""); upb.SetWeiboNickname(""); upb.SetWeiboFlag(0); upb.SetCountry("CN"); UserProfile upObj = upb.Build(); byte[] byteUp = upObj.ToByteArray(); SKBuiltinBuffer_t.Builder skbb = new SKBuiltinBuffer_t.Builder(); skbb.SetBuffer(ByteString.CopyFrom(byteUp)); skbb.SetILen(byteUp.Length); SKBuiltinBuffer_t skbObj = skbb.Build(); CmdItem.Builder cib = new CmdItem.Builder(); cib.SetCmdBuf(skbObj); cib.SetCmdId(1); CmdItem ciObj = cib.Build(); CmdList.Builder clb = new CmdList.Builder(); clb.SetCount(1); clb.AddList(ciObj); CmdList clObj = clb.Build(); NewSyncRequest.Builder nsrb = new NewSyncRequest.Builder(); nsrb.SetOplog(clObj); nsrb.SetSelector(7); nsrb.SetScene(7); SKBuiltinBuffer_t.Builder skb = new SKBuiltinBuffer_t.Builder(); skb.SetBuffer(ByteString.CopyFrom(keyBuffer)); skb.SetILen(keyBuffer.Length); nsrb.SetKeyBuf(skb.Build()); return(nsrb.Build()); }
public static NewSyncRequest ModifyProfile(string nickName, byte[] keyBuffer) { UserProfile.Builder builder = new UserProfile.Builder(); builder.SetBitFlag(2u); builder.SetUserName(new SKBuiltinString_t.Builder().SetString("")); builder.SetNickName(new SKBuiltinString_t.Builder().SetString(nickName)); builder.SetBindUin(0u); builder.SetBindEmail(new SKBuiltinString_t.Builder().SetString("")); builder.SetBindMobile(new SKBuiltinString_t.Builder().SetString("")); builder.SetStatus(0); builder.SetImgLen(0); builder.SetImgBuf(ByteString.CopyFrom("", Encoding.Default)); builder.SetSex(0); builder.SetProvince(""); builder.SetCity(""); builder.SetSignature(""); builder.SetPersonalCard(1); builder.SetPluginFlag(0); builder.SetPluginSwitch(0); builder.SetAlias(""); builder.SetWeiboNickname(""); builder.SetWeiboFlag(0); builder.SetCountry("CN"); UserProfile userProfile = builder.Build(); byte[] array = userProfile.ToByteArray(); SKBuiltinBuffer_t.Builder builder2 = new SKBuiltinBuffer_t.Builder(); builder2.SetBuffer(ByteString.CopyFrom(array)); builder2.SetILen(array.Length); SKBuiltinBuffer_t cmdBuf = builder2.Build(); CmdItem.Builder builder3 = new CmdItem.Builder(); builder3.SetCmdBuf(cmdBuf); builder3.SetCmdId(1); CmdItem value = builder3.Build(); CmdList.Builder builder4 = new CmdList.Builder(); builder4.SetCount(1); builder4.AddList(value); CmdList oplog = builder4.Build(); NewSyncRequest.Builder builder5 = new NewSyncRequest.Builder(); builder5.SetOplog(oplog); builder5.SetSelector(7); builder5.SetScene(7); SKBuiltinBuffer_t.Builder builder6 = new SKBuiltinBuffer_t.Builder(); builder6.SetBuffer(ByteString.CopyFrom(keyBuffer)); builder6.SetILen(keyBuffer.Length); builder5.SetKeyBuf(builder6.Build()); return(builder5.Build()); }
public void SetPressed(ButtonPressEnum buttonPress, bool pressed) { var item = Items.Where(i => i.ButtonStatus == buttonPress).FirstOrDefault(); if (item == null) { item = new CmdItem() { ButtonStatus = buttonPress }; Items.Add(item); } item.Pressed = pressed; Date = DateTime.UtcNow; Source = SourceEnum.Server; }
/// <summary> /// 取消注册命令 /// </summary> /// <param name="cmdId">命令ID</param> public void UnRegisterCommand(int cmdId) { CmdItem removeItem = null; foreach (CmdItem cmdItem in commands) { if (cmdItem.Id == cmdId) { removeItem = cmdItem; break; } } if (removeItem != null) { commands.Remove(removeItem); } }
/// <summary> /// 注册命令(内部使用) /// </summary> /// <param name="keyword">命令单词</param> /// <param name="kernelCallback">命令回调</param> /// <param name="limitArgCount">命令最低参数,默认 0 表示无参数或不限制</param> /// <param name="helpText">命令帮助文字</param> /// <returns>成功返回命令ID,不成功返回-1</returns> /// <returns></returns> public int RegisterCommand(string keyword, CommandDelegate kernelCallback, int limitArgCount, string helpText) { if (!IsCommandRegistered(keyword)) { CmdItem item = new CmdItem(); item.Keyword = keyword; item.LimitArgCount = limitArgCount; item.HelpText = helpText; item.Handler = ""; item.KernelCallback = kernelCallback; item.Id = CommonUtils.GenNonDuplicateID(); commands.Add(item); return(item.Id); } return(-1); }
/// <summary> /// 注册命令 (lua使用) /// </summary> /// <param name="keyword">命令单词</param> /// <param name="handler">命令处理器。命令处理器格式与通用格式相同。LUA接受函数须满足定义:func(keyword, argCount, stringList)</param> /// <param name="limitArgCount">命令最低参数,默认 0 表示无参数或不限制</param> /// <param name="helpText">命令帮助文字</param> /// <returns>成功返回命令ID,不成功返回-1</returns> public int RegisterCommand(string keyword, string handler, int limitArgCount, string helpText) { if (!IsCommandRegistered(keyword)) { CmdItem item = new CmdItem(); item.Keyword = keyword; item.LimitArgCount = limitArgCount; item.HelpText = helpText; item.Handler = handler; item.KernelCallback = null; item.HandlerInternal = new GameLuaHandler(handler); item.Id = CommonUtils.GenNonDuplicateID(); commands.Add(item); return(item.Id); } return(-1); }
public static CmdItem toCmdItem(object o) { try { if (!mapCmdId.ContainsKey(o.GetType())) { Log.e("CmdItemHelper", "can not find object in mapCmdId, o.GetType() = " + o.GetType()); //DebugEx.debugBreak(); return(null); } SyncCmdID did = mapCmdId[o.GetType()]; SKBuiltinBuffer_t _t = Util.toSKBuffer(o.GetType().InvokeMember("ToByteArray", BindingFlags.InvokeMethod, null, o, null) as byte[]); return(CmdItem.CreateBuilder().SetCmdId((int)did).SetCmdBuf(_t).Build()); } catch (Exception exception) { Log.d("CmdItemHelper", "CmdItemHelper ToByteArray error" + exception); } return(null); }
public static CmdList getCmdItemList() { List <OpLog> list = _opList; CmdList.Builder builder = new CmdList.Builder(); if ((list == null) || (list.Count <= 0)) { // Log.e("OpLogMgr", "************ getCmdItemList************"); return(builder.SetCount(0).Build()); } foreach (OpLog log in list) { SKBuiltinBuffer_t _t = Util.toSKBuffer(log.bytesCmdBuf); CmdItem item = CmdItem.CreateBuilder().SetCmdId(log.nCmdId).SetCmdBuf(_t).Build(); if (item != null) { builder.ListList.Add(item); } } return(builder.SetCount((uint)builder.ListList.Count).Build()); }
public static object toCmdObject(CmdItem cmdItem) { try { if (!mapCmdObject.ContainsKey((SyncCmdID)cmdItem.CmdId)) { Log.e("CmdItemHelper", "can not find CmdId in mapCmdObject, cmdItem.CmdId = " + cmdItem.CmdId); if (cmdItem.CmdId != 13) { // DebugEx.debugBreak(); } return(null); } Type type = mapCmdObject[(SyncCmdID)cmdItem.CmdId]; object[] args = new object[] { cmdItem.CmdBuf.Buffer.ToByteArray() }; return(type.InvokeMember("ParseFrom", BindingFlags.InvokeMethod, null, null, args)); } catch (Exception exception) { Log.d("util", "CmdItemHelper parse cmdItem error" + exception); } return(null); }