void ConnectComServer() { Instance = this; RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_RegServer(pkg).GetComServer(pkg); pkg.WaitDoCommand(mRegisterConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut) { RPC.DataReader dr; _io.Read(out dr); string gsIpAddress = ""; UInt16 gsPort = 0; if (dr.Length > 0) { dr.Read(out gsIpAddress); dr.Read(out gsPort); } if (gsIpAddress != "" && gsPort != 0) { if (mLinkState == PlanesServerState.WaitRegServer) { mComConnect.Connect(gsIpAddress, gsPort); System.Diagnostics.Debug.WriteLine("PlanesServer成功连接RegServer,尝试连接DataServer:" + gsIpAddress + ":" + gsPort); } else { mComConnect.Connect(gsIpAddress, gsPort); System.Diagnostics.Debug.WriteLine("PlanesServer断线,重新从RegServer获得地址,尝试连接DataServer:" + gsIpAddress + ":" + gsPort); } } }; }
public void RPC_CreateSummon(RPC.PackageWriter pkg, System.UInt64 ownerId, System.UInt64 targetid, System.Int32 skillid) { pkg.Write(ownerId); pkg.Write(targetid); pkg.Write(skillid); pkg.SetMethod(2); }
public void TryCreatePlayer(UInt16 lnk, ulong accountId, string planeName, string plyName, Byte pro, Byte sex, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd) { //planesName = ServerFrame.DB.DBConnect.SqlSafeString(planesName); plyName = ServerFrame.DB.DBConnect.SqlSafeString(plyName); ulong roleId = ServerFrame.Util.GenerateObjID(ServerFrame.GameObjectType.Player); AsyncExecuter exe = AsyncExecuteThreadManager.Instance.AsyncExe(false); UInt16 returnSerialId = fwd.ReturnSerialId; exe.Exec = delegate() { RPC.PackageWriter retPkg = new RPC.PackageWriter(); CSCommon.Data.PlayerData result = mPlayerManager.TryCreatePlayer(Thread.PlayerEnterThread.Instance.DBConnect, mPlanesMgr, accountId, roleId, planeName, plyName, pro, sex); //告诉GateServer,创建是否成功 if (result != null) { retPkg.Write((sbyte)1); retPkg.Write(result.RoleDetail); retPkg.DoReturnCommand2(connect, returnSerialId); } else { retPkg.Write((sbyte)-1); retPkg.DoReturnCommand2(connect, returnSerialId); } }; //这里要放到一个专门的队列创建 Thread.PlayerEnterThread.Instance.PushRoleCreator(exe); }
public void RPC_GetTeamPlayers(RPC.RPCForwardInfo fwd) { RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_GetTeamPlayers(pkg, PlayerData.RoleDetail.RoleId); pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool isTimeOut) { if (isTimeOut) { return; } RPC.PackageWriter retPkg = new RPC.PackageWriter(); retPkg.SetSinglePkg(); sbyte result = _io.ReadSByte(); retPkg.Write(result); if (result == (sbyte)CSCommon.eRet_Team.Succeed) { byte count = _io.ReadByte(); retPkg.Write(count); for (byte i = 0; i < count; i++) { RoleCom data = new RoleCom(); _io.Read(data); retPkg.Write(data); } } retPkg.DoReturnPlanes2Client(fwd); }; }
public void RPC_NpcReborn(RPC.PackageWriter pkg, System.Single x, System.Single y, System.Single z) { pkg.Write(x); pkg.Write(y); pkg.Write(z); pkg.SetMethod(9); }
void OnRegisterConnected(Iocp.TcpClient pClient, byte[] pData, int nLength) { if (nLength == 0) { return; } RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_RegServer(pkg).RegComServer(pkg, mParameter.ListenIP, mParameter.ServerId); pkg.WaitDoCommand(mRegisterConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut) { System.Diagnostics.Debug.WriteLine("公共信息通讯服务器({0})启动并且注册成功,可以等待位面服务器接入了", mParameter.ServerId); UInt16 listenPort = 0; _io.Read(out listenPort); mParameter.ListenPort = listenPort; if (mLinkState != ComServerState.Working) { if (false == mTcpSrv.Open(Iocp.TcpOption.ForComServer, mParameter.ListenPort)) { return; } } mLinkState = ComServerState.Working; }; }
public void RPC_CreateGuild(string GuildName, RPC.RPCForwardInfo fwd) { RPC.PackageWriter retPkg = new RPC.PackageWriter(); if (!_IsLevelEnough(CSCommon.GuildCommon.Instance.NeedRoleLevel)) { retPkg.Write((sbyte)CSCommon.eRet_CreateGuild.LessLevel); retPkg.DoReturnPlanes2Client(fwd); return; } if (!_IsMoneyEnough(CSCommon.GuildCommon.Instance.NeedCurrenceType, CSCommon.GuildCommon.Instance.NeedMoneyNum)) { retPkg.Write((sbyte)CSCommon.eRet_CreateGuild.LessRmb); retPkg.DoReturnPlanes2Client(fwd); return; } RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_CreateGuild(pkg, PlayerData.RoleDetail.RoleId, GuildName); pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool isTimeOut) { if (isTimeOut) { return; } SByte success; _io.Read(out success); retPkg.Write(success); if (success == (sbyte)CSCommon.eRet_CreateGuild.Succeed) { _ChangeMoney(CSCommon.GuildCommon.Instance.NeedCurrenceType, CSCommon.Data.eMoneyChangeType.CreateGuild, -CSCommon.GuildCommon.Instance.NeedMoneyNum); } retPkg.DoReturnPlanes2Client(fwd); }; }
public void RPC_OnJumpMapOver(RPC.PackageWriter pkg, System.Int32 mapid, System.Single posx, System.Single posz) { pkg.Write(mapid); pkg.Write(posx); pkg.Write(posz); pkg.SetMethod(17); }
public void RPC_OneKeyGetItems(RPC.RPCForwardInfo fwd) { RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_OneKeyGetItems(pkg, PlayerData.RoleDetail.RoleId); pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool isTimeOut) { if (isTimeOut) { return; } RPC.PackageWriter retPkg = new RPC.PackageWriter(); List <CSCommon.Data.MailData> mails = new List <CSCommon.Data.MailData>(); int count = 0; _io.Read(out count); for (int i = 0; i < count; i++) { CSCommon.Data.MailData mail = new CSCommon.Data.MailData(); _io.Read(mail); if (_GetMailItems(mail.StrItems) == false) { retPkg.Write((sbyte)-1); //背包空间不足 retPkg.DoReturnPlanes2Client(fwd); return; } _GetMailCurrencies(mail.StrCurrencies); //删除邮件 RPC.PackageWriter delpkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(delpkg).HGet_UserRoleManager(delpkg).RPC_DelMail(delpkg, mail.MailId); delpkg.DoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType); } retPkg.Write((sbyte)1); retPkg.DoReturnPlanes2Client(fwd); }; }
public void RPC_DonateGold(int gold, RPC.RPCForwardInfo fwd) { RPC.PackageWriter retPkg = new RPC.PackageWriter(); if (_IsMoneyEnough(CSCommon.eCurrenceType.Gold, gold) == false) { retPkg.Write((sbyte)CSCommon.eRet_DonateGold.LessGold); retPkg.DoReturnPlanes2Client(fwd); return; } RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_DonateGold(pkg, PlayerData.RoleDetail.RoleId, gold); pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool isTimeOut) { if (isTimeOut) { return; } sbyte success; _io.Read(out success); retPkg.Write(success); if (success == (sbyte)CSCommon.eRet_DonateGold.Succeed) { int todaycontribute; int contribute; _io.Read(out todaycontribute); _io.Read(out contribute); retPkg.Write(todaycontribute); retPkg.Write(contribute); _ChangeMoney(CSCommon.eCurrenceType.Gold, CSCommon.Data.eMoneyChangeType.GuildContribute, gold); } retPkg.DoReturnPlanes2Client(fwd); }; }
public void RPC_GetMails(RPC.RPCForwardInfo fwd) { RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_GetMails(pkg, PlayerData.RoleDetail.RoleId); pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool isTimeOut) { if (isTimeOut) { return; } RPC.PackageWriter retPkg = new RPC.PackageWriter(); retPkg.SetSinglePkg(); List <CSCommon.Data.MailData> mails = new List <CSCommon.Data.MailData>(); int count = 0; _io.Read(out count); retPkg.Write(count); for (int i = 0; i < count; i++) { CSCommon.Data.MailData mail = new CSCommon.Data.MailData(); _io.Read(mail); retPkg.Write(mail); } retPkg.DoReturnPlanes2Client(fwd); }; }
public void RPC_CreateTeam(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd) { RPC.PackageWriter pkg = new RPC.PackageWriter(); var role = GetRole(roleId); if (role == null) { pkg.Write((sbyte)CSCommon.eRet_Team.NoRole); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } if (role.TeamHeaderId != 0) { pkg.Write((sbyte)CSCommon.eRet_Team.RoleHasTeam); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } if (_CreateTeam(roleId) == false) { pkg.Write((sbyte)CSCommon.eRet_Team.NewTeamError); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } if (_AddTeam(role, roleId) == false) { pkg.Write((sbyte)CSCommon.eRet_Team.OverTeamCount); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } pkg.Write((sbyte)CSCommon.eRet_Team.Succeed); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); }
public static void CreatePlayerImage(CSCommon.MapInfo_Npc nd, MapInstance map, ulong playerId) { PlayerImage ret = new PlayerImage(); ret.mId = ServerFrame.Util.GenerateObjID(ServerFrame.GameObjectType.PlayerImage); RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_GetOffPlayerData(pkg, playerId); pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut) { CSCommon.Data.RoleCom rc = new CSCommon.Data.RoleCom(); _io.Read(rc); OffPlayerData pd = new OffPlayerData(); pd.Deserizle(rc); ret.InitPlayerData(pd, rc); var init = new NpcInit(); init.GameType = eActorGameType.PlayerImage; init.Data = nd; init.OwnerMapData = map.MapInfo; if (!ret.Initialize(init)) { return; } ret.mAttackTarget = playerId; ret.Reborn(); ret.OnEnterMap(map); }; }
public RPC.DataWriter GetPlanesServers() { RPC.DataWriter d = new RPC.DataWriter(); Byte count = (Byte)mPlanesServers.Count; d.Write(count); foreach (var s in mPlanesServers) { if (s.Value.Id == 0) { Log.Log.Server.Print("GetPlanesServers时有的PlanesSever的Id不合法"); RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_PlanesServer(pkg).GetPlanesServerId(pkg); pkg.WaitDoCommand(s.Value.Connect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut) { _io.Read(out s.Value.Id); }; } d.Write(s.Value.Id); d.Write(s.Value.Ip); d.Write(s.Value.Port); } return(d); }
public void RPC_BuyConsignItem(ulong roleId, ulong itemId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd) { RPC.PackageWriter pkg = new RPC.PackageWriter(); var role = GetRole(roleId); if (role == null) { pkg.Write((sbyte)CSCommon.eRet_BuyConsignItem.NoRole); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } var gird = GetGird(itemId); if (gird == null) { pkg.Write((sbyte)CSCommon.eRet_BuyConsignItem.NoItem); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } string items = GetStr(gird.TemplateId, gird.StackNum); CreateMailAndSend(roleId, CSCommon.eMailFromType.BuyConsignSucceed, "", items); DB_DelGird(gird); pkg.Write((sbyte)CSCommon.eRet_BuyConsignItem.Succeed); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); }
public void RPC_ItemAdd2Bag(RPC.PackageWriter pkg, CSCommon.Data.ItemData data, System.Byte bag, System.UInt16 pos) { pkg.Write(data); pkg.Write(bag); pkg.Write(pos); pkg.SetMethod(4); }
public void RPC_GetRoleGirdByType(ulong roleId, byte itemType, byte page, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd) { RPC.PackageWriter pkg = new RPC.PackageWriter(); var role = GetRole(roleId); if (role == null) { pkg.Write((sbyte)-1); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } pkg.Write((sbyte)1); byte pageNum = 5; int start = (page - 1) * pageNum; string strSQL = "select * from ConsignGirdData where Type = " + itemType.ToString() + "limit start,pageNum"; List <CSCommon.Data.ConsignGridData> datas = SelectGird(strSQL); int count = datas.Count; pkg.Write(count); for (int i = 0; i < count; i++) { pkg.Write(datas[i]); } pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); }
public void RPC_Killed(RPC.PackageWriter pkg, System.Int32 skillId, System.Int32 level, System.UInt64 targetId) { pkg.Write(skillId); pkg.Write(level); pkg.Write(targetId); pkg.SetMethod(7); }
public static void SendMsg2Client(PlayerInstance player, CSCommon.Data.Message msg) { RPC.PackageWriter pkg = new RPC.PackageWriter(); pkg.SetSinglePkg(); Wuxia.H_RpcRoot.smInstance.RPC_ReceiveMsg(pkg, msg); pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId); }
public void RPC_UpdateBuff(RPC.PackageWriter pkg, System.Int32 buffId, System.Int32 level, System.Int32 time) { pkg.Write(buffId); pkg.Write(level); pkg.Write(time); pkg.SetMethod(12); }
public void RPC_Whisper(string targetName, string msg, RPC.DataReader hyperlink, RPC.RPCForwardInfo fwd) { sbyte success = 0; RPC.DataWriter data = new RPC.DataWriter(); if (hyperlink != null) { hyperlink.Read(out success); data.Write(success); if (success == (sbyte)1)//物品 { CSCommon.Data.ItemData item = new CSCommon.Data.ItemData(); hyperlink.Read(item, true); data.Write(item, true); } } msg = CheckMaskWord(msg); RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_SayToRole(pkg, this.Id, targetName, msg, data); pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut) { sbyte result = -1; _io.Read(out result); if (result < 0) { SendTalkMsg2Client(this, (sbyte)CSCommon.eSayChannel.WhisperChannel, "", "无效发送对象", new RPC.DataWriter()); } else { SendTalkMsg2Client(this, (sbyte)CSCommon.eSayChannel.WhisperChannel, this.RoleName, msg, data); } }; }
void OnRegisterConnected(Iocp.TcpClient pClient, byte[] pData, int nLength) { if (nLength == 0) { return; } RPC.PackageWriter pkg = new RPC.PackageWriter(); //System.String[] ips = Iocp.TcpServer.GetHostIpAddress(); //mParameter.ListenIP = mParameter.//SelectDataServerIP(ips); H_RPCRoot.smInstance.HGet_RegServer(pkg).RegDataServer(pkg, mParameter.ListenIP, mParameter.ListenPort, mParameter.ServerId); pkg.WaitDoCommand(mRegisterConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut) { System.Diagnostics.Debug.WriteLine("数据服务器({0})启动并且注册成功,可以等待连接服务器接入了", mParameter.ServerId); if (mLinkState != DataServerState.Working) { if (false == mTcpSrv.Open(Iocp.TcpOption.ForDataServer, mParameter.ListenPort)) { return; } } mLinkState = DataServerState.Working; }; }
void OnRegisterConnected(Iocp.TcpClient pClient, byte[] pData, int nLength) { if (nLength == 0) { return; } RPC.PackageWriter pkg = new RPC.PackageWriter(); //System.String[] ips = Iocp.TcpServer.GetHostIpAddress(); //mParameter.ListenIP = SelectDataServerIP(ips); H_RPCRoot.smInstance.HGet_RegServer(pkg).RegPlanesServer(pkg, mParameter.ServerId); pkg.WaitDoCommand(mRegisterConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut) { UInt16 port; _io.Read(out port); mParameter.ListenPort = port; System.Diagnostics.Debug.WriteLine("位面服务器({0})启动并且注册成功,可以等待连接服务器接入了", mParameter.ServerId); mLinkState = PlanesServerState.WaitDataServer; //ConnectDataServer(); //ConnectPathFindServer(); }; }
private void DB_RoleEnteInitMessages(UserRole role)//只有登录的时候调用 { string condition = "OwnerId=" + role.RoleData.RoleId; ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CSCommon.Data.Message(), ""); System.Data.DataTable tab = mDBConnect._ExecuteSelect(dbOp, "Message"); if (tab != null) { foreach (System.Data.DataRow r in tab.Rows) { CSCommon.Data.Message msg = new CSCommon.Data.Message(); if (false == ServerFrame.DB.DBConnect.FillObject(msg, r)) { continue; } DB_DelMessage(msg); //发送消息 RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_PlanesServer(pkg).RPC_SendPlayerMsg(pkg, role.RoleData.RoleId, msg); pkg.DoCommand(role.PlanesConnect, RPC.CommandTargetType.DefaultType); } } else { System.Diagnostics.Debug.WriteLine("角色获取信息数据库执行失败:" + dbOp.SqlCode); } }
public void RPC_ItemStackNumChanged(RPC.PackageWriter pkg, System.UInt64 itemId, System.Byte bag, System.Int32 num) { pkg.Write(itemId); pkg.Write(bag); pkg.Write(num); pkg.SetMethod(3); }
public UInt16 RegPlanesServer(ulong id, Iocp.NetConnection connect) { if (id == 0) { Log.Log.Server.Print("RegPlanesServer id is Empty"); } ServerInfo si = connect.m_BindData as ServerInfo; si.Id = id; Iocp.TcpConnect tcpConnect = connect as Iocp.TcpConnect; si.Ip = tcpConnect.IpAddress; si.LinkNumber = 0; mPlanesServers[connect] = si; Log.Log.Server.Print("Planes服务器{0}注册,{1}:{2}", si.Id, si.Ip, si.Port); foreach (var i in mGateServers) { //i.Value.Connect RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_GateServer(pkg).NewPlanesServerStarted(pkg); pkg.DoCommand(i.Value.Connect, RPC.CommandTargetType.DefaultType); } return(si.Port); }
public void RPC_Say(RPC.PackageWriter pkg, System.UInt64 roleId, System.SByte channel, System.String msg, RPC.DataWriter hyperlink) { pkg.Write(roleId); pkg.Write(channel); pkg.Write(msg); pkg.Write(hyperlink); pkg.SetMethod(47); }
public void TryRegAccount(RPC.PackageWriter pkg, System.UInt16 cltLinker, System.String usr, System.String psw, System.String mobileNum) { pkg.Write(cltLinker); pkg.Write(usr); pkg.Write(psw); pkg.Write(mobileNum); pkg.SetMethod(3); }
public void RPC_SayToRole(RPC.PackageWriter pkg, System.UInt64 roleId, System.String tarName, System.String msg, RPC.DataWriter hyperlink) { pkg.Write(roleId); pkg.Write(tarName); pkg.Write(msg); pkg.Write(hyperlink); pkg.SetMethod(46); }
public void RPC_GetRoleGirdByName(RPC.PackageWriter pkg, System.UInt64 roleId, System.String name, System.Byte findType, System.Byte page) { pkg.Write(roleId); pkg.Write(name); pkg.Write(findType); pkg.Write(page); pkg.SetMethod(9); }