public void ClientConnect() { NetPeerObject.Start(); NetClientObject.DiscoverLocalPeers(PortNum); NetPeerObject.Connect(host: HostAddress, port: PortNum); StartListning(); }
public void SendSystemDataRequest(Guid systemID) { NetOutgoingMessage msg = NetPeerObject.CreateMessage(); msg.Write((byte)ToServerMsgType.RequestSystemData); msg.Write(systemID.ToByteArray()); NetClientObject.SendMessage(msg, NetClientObject.ServerConnection, NetDeliveryMethod.ReliableOrdered); }
public void SendEntityHashRequest(Guid entityGuid) { NetOutgoingMessage msg = NetPeerObject.CreateMessage(); msg.Write((byte)ToServerMsgType.RequestEntityHash); msg.Write(entityGuid.ToByteArray()); NetClientObject.SendMessage(msg, NetClientObject.ServerConnection, NetDeliveryMethod.ReliableOrdered); }
/// <summary> /// Sends the faction data request. and sets up a link between this connection and a faction. /// </summary> /// <param name="factionName">Faction.</param> /// <param name="password">Password.</param> public void SendFactionDataRequest(string factionName, string password) { NetOutgoingMessage sendMsg = NetPeerObject.CreateMessage(); sendMsg.Write((byte)ToServerMsgType.RequestFactionEntityData); sendMsg.Write(factionName); sendMsg.Write(password); Encrypt(sendMsg);//sequence channel 31 is expected to be encrypted by the recever. see NetworkBase GotMessage() NetClientObject.SendMessage(sendMsg, NetClientObject.ServerConnection, NetDeliveryMethod.ReliableOrdered, SecureChannel); }
public void SendDatablobRequest(Guid entityID, Type datablobType) { //TODO: datablobs have an int ID, can we use that? can we be sure that the server and client's datablob IDs are the same? NetOutgoingMessage msg = NetPeerObject.CreateMessage(); msg.Write((byte)ToServerMsgType.RequestDatablob); msg.Write(entityID.ToByteArray()); //EntityID msg.Write(datablobType.Name); //type. msg.Write(EntityManager.DataBlobTypes[datablobType]); //typeIndex NetClientObject.SendMessage(msg, NetClientObject.ServerConnection, NetDeliveryMethod.ReliableOrdered); }
public void SendEntityCommand(EntityCommand cmd) { Guid cmdID = Guid.NewGuid(); CommandsAwaitingServerAproval.Add(cmdID, cmd); NetOutgoingMessage sendMsg = NetPeerObject.CreateMessage(); var mStream = new MemoryStream(); SerializationManager.Export(Game, mStream, cmd); byte[] byteArray = mStream.ToArray(); int len = byteArray.Length; sendMsg.Write((byte)ToServerMsgType.SendPlayerEntityCommand); sendMsg.Write(cmdID.ToByteArray()); sendMsg.Write(cmd.GetType().Name); sendMsg.Write(len); sendMsg.Write(byteArray); NetClientObject.SendMessage(sendMsg, NetClientObject.ServerConnection, NetDeliveryMethod.ReliableOrdered); Messages.Add("Sent Command " + cmd.CmdID); }