// Send a commond public void SendCommond() { CommondInfo commond = new CommondInfo() { func = "test", param = "hello,world,1,2,3" }; client.SendMsg(MsgId.Commond, Target.All, commond); }
static void Main(string[] args) { //没有命令无法执行 if (args == null || args.Length == 0) { Console.WriteLine("No commond !"); return; } //args = new string[] { "-x", "-c", "-l" }; //获取指令蕴含信息 CommondInfo info = CommondReader.GetInfo(args); //错误处理 if (info.isError) { ErrorHanding(info.errorType); return; } //生成计数器 WordCounter counter = new WordCounter(); counter.AddFunction(info.funcs); string data; //获取信息 if (!FileDataReader.GetDataByPath(info.filePath, out data)) { Console.WriteLine("Open file failed !"); return; } //设置信息并进行计数 counter.SetString(data); //输出 Console.WriteLine(counter.GetAllLogs()); //Console.ReadKey(); }
public static string GetString(this CommondInfo msg) { return(string.Format("func:{0} param:{1}", msg.func, msg.param)); }
void Start() { client = ColyseusClient.instance; GetServerList(); client.AddListener(MsgId.Commond, OnCommandResp); client.AddListener(MsgId.Connect, OnConnectResp); client.AddListener(MsgId.DisConnect, OnDisConnectResp); client.AddListener(MsgId.CreateANetObject, OnCreateANetObjectResp); //client.AddListener(MsgId.CreateARoom, OnCreateARoomResp); client.AddListener(MsgId.DestroyANetObject, OnDestroyANetObjectResp); //client.AddListener(MsgId.GetRoomList, OnGetRoomListResp); //client.AddListener(MsgId.JoinARoom, OnJoinARoomResp); //client.AddListener(MsgId.LeaveARoom, OnLeaveARoomResp); client.AddListener(MsgId.StartGame, OnStartGameResp); client.AddListener(MsgId.UpdateRoomInfo, OnUpdateRoomInfo); #region btn event ConnectBtn.onClick.AddListener(() => { //test :192.168.71.140 client.ConnectToServer(ServerList[(int)serverType], "2567", (result, obj) => { if (result == ColyseusClient.ColyseusClientResult.Success) { Debug.Log("Connect server success!!!"); } else { Debug.Log("Connect server failed!!!"); } }); }); GetRoomBtn.onClick.AddListener(() => { client.GetAvailableRooms((result, obj) => { if (result == ColyseusClient.ColyseusClientResult.Success) { Debug.Log("Get rooms success!!!"); OnGetRoomListResp(obj); } else { Debug.Log("Get rooms failed!!!"); } }); //client.SendMsg(MsgId.GetRoomList, Target.Owner, null); }); CreateRoomBtn.onClick.AddListener(() => { client.CreateRoom("testRoom", "123456", (result, obj) => { if (result == ColyseusClient.ColyseusClientResult.Success) { Debug.Log("Create Room success!!!"); OnCreateARoomResp(obj); } else { Debug.Log("Create Room failed :" + obj); } }); }); JoinRoomBtn.onClick.AddListener(() => { client.JoinOrCreateRoom("123456", (result, obj) => { if (result == ColyseusClient.ColyseusClientResult.Success) { Debug.Log("Join a room success!!!"); } else { Debug.Log("Join a room failed! error code is :" + obj); } }); }); LeaveRoomBtn.onClick.AddListener(() => { client.LeaveRoom((result, obj) => { if (result == ColyseusClient.ColyseusClientResult.Success) { Debug.Log("Leave Room success!!!"); OnLeaveARoomResp(obj); } else { Debug.Log("Leave Room failed!!!"); } }); }); SendMsgBtn.onClick.AddListener(() => { SendCommond(); }); CreateBossBtn.onClick.AddListener(() => { CreateAEnemy(); }); ShootBossBtn.onClick.AddListener(() => { CommondInfo commond = new CommondInfo() { func = "damage", param = string.Format("{0},{1}", boss.enemyInfo.id, 0.1f) }; client.SendMsg(MsgId.Commond, Target.All, commond); }); StartGameBtn.onClick.AddListener(() => { client.SendMsg(MsgId.StartGame, Target.All, null); }); EndGameBtn.onClick.AddListener(() => { client.SendMsg(MsgId.EndGame, Target.Server, null); }); UploadScoresBtn.onClick.AddListener(() => { var ScoreInfo = new ScoreInfo(); ScoreInfo.scores = new ScoreItem[4]; ScoreInfo.scores[0] = new ScoreItem() { clientID = "11111", score = 12 }; ScoreInfo.scores[1] = new ScoreItem() { clientID = "22222", score = 12 }; ScoreInfo.scores[2] = new ScoreItem() { clientID = "33333", score = 12 }; ScoreInfo.scores[3] = new ScoreItem() { clientID = "44444", score = 12 }; client.SendMsg(MsgId.UploadScores, Target.Server, ScoreInfo); }); UploadDeviceinfoBtn.onClick.AddListener(() => { client.SendMsg(MsgId.UploadDeviceInfo, Target.Server, new AppInfo() { snCode = "0000-1111", macAddress = Utils.GetMacAddress(), startUpTimeStamp = 112312123 });; }); #endregion }