void SendMessageAddRanking(string name, int score) { protos.integral.ReqAddTop top = new protos.integral.ReqAddTop(); top.userName = name; top.integral = score; GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqAddTop, top)); }
protected override void SaveClient(ClientBase client) { ServerClient sClient = client as ServerClient; GameServerMgr.AddClient(sClient); sClient.ClientDisconnectHandler += new ClientBase.ClientDisconnectedDelegate(cClient_ClientDisconnectHandler); }
/// <summary> /// 获取单例 /// </summary> /// <returns></returns> public static GameServerMgr GetInstance() { if (!hasIntance) { if (isDestorying) { return(null); } mInstance = new GameObject("_GameServerMgr").AddComponent <GameServerMgr>(); } return(mInstance); }
static void Main(string[] args) { ResourceUtil.ExtractResource("LogConfig.xml", "LogConfig.xml", Assembly.GetAssembly(typeof(Program))); //ResourceUtil.ExtractResourceSafe("LogConfig.xml", "LogConfig.xml", Assembly.GetAssembly(typeof(Program))); //ResourceUtil.ExtractResource("server.config", "server.config", Assembly.GetAssembly(typeof(Program))); //ResourceUtil.ExtractResourceSafe("server.config", "server.config", Assembly.GetAssembly(typeof(Program))); //GSConfigMgr.LoadGameServerConfig("server.config"); GameServerMgr.DisabledCloseBtn(); CommandMgr.Instance.SearchCommand(Assembly.GetAssembly(typeof(GSServer))); Console.WriteLine("指令系统初始化成功!!!\r\n"); if (!CommandMgr.Instance.ExecuteCommand("LoadGameConfig")) { GameServerMgr.PressKeyExit(); return; } if (!CommandMgr.Instance.ExecuteCommand("AllocBuffer")) { GameServerMgr.PressKeyExit(); return; } if (!CommandMgr.Instance.ExecuteCommand("SetupPackageHandler")) { GameServerMgr.PressKeyExit(); return; } if (!CommandMgr.Instance.ExecuteCommand("ListenLocal")) { GameServerMgr.PressKeyExit(); return; } GameServerMgr.ConnectCenterServer(); FightServerMgr.ConnectFightServers(); GameServerMgr.Success(); Console.WriteLine("游戏服务器启动成功!!!\r\n"); GameServerMgr.WaitingInputCmd("GameServer"); }
private void cClient_ClientDisconnectHandler(ClientBase client) { ServerClient sClient = client as ServerClient; sClient.ClientDisconnectHandler -= new ClientBase.ClientDisconnectedDelegate(cClient_ClientDisconnectHandler); GameServerMgr.RemoveClient(sClient); if (sClient.Socket != null) { byte[] temp = sClient.Socket.SendBuffer; sClient.Socket.SendBuffer = null; BufferMgr.ReleaseBuffer(temp); temp = sClient.Socket.ReceiveBuffer; sClient.Socket.ReceiveBuffer = null; BufferMgr.ReleaseBuffer(temp); } }
void Start() { WBGM = Instantiate(Resources.Load("Prefabs/WBGM")) as GameObject; GameServerMgr.GetInstance().RegisterNotifier(NetMessageDef.ResGetTopList, this); GameStartTransform.gameObject.SetActive(true); GamePlayTransform.gameObject.SetActive(false); RankingTransform.gameObject.SetActive(false); ScoreUpdateTransform.gameObject.SetActive(false); Item.gameObject.SetActive(false); mScore = GridCentrerTransform.Find("Score").GetComponent <Text>(); //TimeText = GridCentrerTransform.Find("TimeText").GetComponent<Text>(); //TimeBar = GridCentrerTransform.Find("Timebar").GetComponent<Scrollbar>(); mSteps = GridCentrerTransform.Find("Schritt").GetComponent <Text>(); ScoreUp = ScoreUpdateTransform.Find("ScoreUp").GetComponent <Text>(); input = ScoreUpdateTransform.Find("InputField").GetComponent <InputField>(); }
// Use this for initialization void Start() { //注册收听器 GameServerMgr.GetInstance().RegisterNotifier(NetMessageDef.ResFriendList, this); GameServerMgr.GetInstance().RegisterNotifier(NetMessageDef.ResLogin, this); GameServerMgr.GetInstance().RegisterNotifier(NetMessageDef.ResReturnDefaultInfo, this); GameServerMgr.GetInstance().RegisterNotifier(NetMessageDef.ResFindFriendList, this); GameServerMgr.GetInstance().RegisterNotifier(NetMessageDef.ResGetTopList, this); //protos.Login.ReqLogin loginTest = new protos.Login.ReqLogin(); //loginTest.account = "s001"; //loginTest.password = "******"; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg(100, loginTest)); //protos.Login.ReqCreateAccount createAccount = new protos.Login.ReqCreateAccount(); //createAccount.account = "s003"; //createAccount.password = "******"; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqCreateAccount, createAccount)); //protos.Login.ReqLogin createAccount = new protos.Login.ReqLogin(); //createAccount.account = "s001"; //createAccount.password = "******"; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqLogin, createAccount)); //测试添加积分 //protos.integral.ReqAddTop addTop = new protos.integral.ReqAddTop(); //addTop.userName = "******"; //addTop.integral = 1024; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqAddTop, addTop)); protos.integral.ReqGetTopListSan getTopListSan = new protos.integral.ReqGetTopListSan(); getTopListSan.topNums = 10; GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqGetTopListSan, getTopListSan)); //GameServerMgr.GetInstance().Test(); }
public bool Execute(string[] paramsList) { Console.WriteLine(" 当前有 {0} 个游戏服务器正在运行!", GameServerMgr.GetClientCount()); if (paramsList.Length == 0) { return(true); } string param = CommandMgr.GetParam("-ip", paramsList); if (!string.IsNullOrEmpty(param)) { ServerClient[] list = GameServerMgr.GetAllClient(); for (int i = 0; i < list.Length; i++) { CommandMgr.WriteLine(8, (i + 1).ToString() + ")", 4, list[i].Socket.RemoteEndPoint); } } return(true); }
public void OnReceiveData(uint cmdId, object param1, object param2) { if (cmdId == NetMessageDef.ResLogin) { protos.Login.ResLogin info = param1 as protos.Login.ResLogin; Debug.Log("结果类型:" + info.results); Debug.Log("结果细节:" + info.details); //protos.friend.ReqGetFriendList getFriendList = new protos.friend.ReqGetFriendList(); //getFriendList.feiendId = 1; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqGetFriendList, getFriendList)); //protos.friend.ReqGiveVigor giveVigor = new protos.friend.ReqGiveVigor(); //giveVigor.feiendId = 2; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqGiveVigor, giveVigor)); //protos.friend.ReqAddFriend addFriend = new protos.friend.ReqAddFriend(); //addFriend.feiendId = 2; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqAddFriend, addFriend)); //protos.friend.ReqDeleteFriend addFriend = new protos.friend.ReqDeleteFriend(); //addFriend.feiendId = 2; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqDeleteFriend, addFriend)); //protos.friend.ReqFindFriend addFriend = new protos.friend.ReqFindFriend(); //addFriend.name = "王"; //addFriend.page = 1; //addFriend.pageSize = 10; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqFindFriend, addFriend)); //protos.integral.ReqAddIntegral addIntegral = new protos.integral.ReqAddIntegral(); //addIntegral.userId = 1; //addIntegral.integral = 10; //GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqAddIntegral, addIntegral)); protos.integral.ReqGetTopList getTopList = new protos.integral.ReqGetTopList(); getTopList.topNums = 10; GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqGetTopList, getTopList)); } else if (cmdId == NetMessageDef.ResFriendList) { protos.friend.ResFriendList list = param1 as protos.friend.ResFriendList; //protos.friend.UserInfo foreach (protos.friend.UserInfo info in list.userInfo) { Debug.Log(string.Format("name={0} lv={1} id={2}", info.name, info.lv, info.uid)); } Debug.Log("好友个数:" + list.userInfo.Count); } else if (cmdId == NetMessageDef.ResReturnDefaultInfo) { protos.ReturnMessage.ResDefaultInfo info = param1 as protos.ReturnMessage.ResDefaultInfo; Debug.Log("结果:" + info.results); Debug.Log("细节:" + info.details); } else if (cmdId == NetMessageDef.ResFindFriendList) { protos.friend.ResFindFriendList list = param1 as protos.friend.ResFindFriendList; foreach (protos.friend.UserInfo info in list.userInfo) { Debug.Log(string.Format("name={0} lv={1} id={2}", info.name, info.lv, info.uid)); } Debug.Log("符合条件用户个数:" + list.userInfo.Count); } else if (cmdId == NetMessageDef.ResGetTopList) { protos.integral.ResGetTopList list = param1 as protos.integral.ResGetTopList; foreach (protos.integral.TopInfo info in list.topInfo) { Debug.Log(string.Format("name={0} lv={1} id={2} integral={3}", info.name, info.lv, info.uid, info.integral)); } Debug.Log("排行榜用户个数:" + list.topInfo.Count); } }
/// <summary>请求排行榜列表</summary> void SendMessageGetRankingList(int num) { protos.integral.ReqGetTopListSan san = new protos.integral.ReqGetTopListSan(); san.topNums = num; GameServerMgr.GetInstance().SendMessage(new MuffinMsg((int)NetMessageDef.ReqGetTopListSan, san)); }