// For example, category = 1 means difficulty HARDuint category =1;// Room name that you may assign to the roomstring roomName ="For hardcore players only";// Any information that you may want to assign to the roomstring roomMetadata ="No noob allowed lol";// Capture the server response of room.Registerroom.OnRegister+= (bool success,byte[] message) =>{ // This event is the response of room.Register}// This is how to assign the category to a room that the client has already joinedroom.Register(category, roomName, roomMetadata)
個別ロビー(ルーム)をカテゴリごとに検索する
NOTE: 以下のコード例では C# Client SDK を使っています。
// For example, category = 1 means difficulty HARDuint category =1;// This controls how many rooms to retrieveuint howManyItemsToRetrieve =10;// This capture the server response to receive the list of roomsroom.OnFindRoomsByType+= (bool success,List<RoomListItem> rooms) =>{ // Loop the list to work your magic!for (int i =0; i <rooms.Cont; i++) {string roomID =rooms[i].GetID();string roomName =rooms[i].GetName();string roomMetadata =rooms[i].GetMetadata(); }}// This is how to request for the list of roomsroom.FindRoomsByType(category, howManyItemsToRetrieve);
// This is the listener callback to capture and handle messages sent by room.BroadcastTo from remote playersroom.OnMemberBroadcast+= (byte[] message) =>{ // Deserialize the message using Diarkis.Lib.SyncDataDiarkis.Lib.SyncData syncdata =newDiarkis.Lib.SyncData();syncData.Deserialize(message); // These are the properties from the deserialized messageDictionary<string,object> properties =syncData.Properties;long remotePlayerPositionX =properties.Get("x");long remotePlayerPositionY =properties.Get("y");long remotePlayerVelocity =properties.Get("velocity"); // This is the player ID of the remote playerstring remotePlayerUID =syncdata.UID;}// Properties to be serialized and sentDictionary<string, object> properties =newDictionary<string,object>();properties.Add("x", playerPositionX);properties.Add("y", playerPositionY);properties.Add("velocity", playerVelocity);// Serialize the property data to be sent as a messageDiarkis.Lib.SyncData syncdata =newDiarkis.Lib.SyncData();syncdata.UID= playerUID; // Player IDsyncdata.Properties= properties;syncdata.Serialize();byte[] message =syncdata.Serialized;// If UDP client is used setting this flag to true will make the message delivered as an RUDP messagebool reliable =false;// This is how to send a message to all members in the lobbyroom.BroadcastTo(room.GetRoomID(), message, reliable);
ロビー参加メンバーの一部(任意に選定した)に対してメッセージを送受信する
NOTE: 以下のコード例では C# Client SDK を使っています。
// This is the listener callback to capture and handle messages sent by room.MessageTo from remote playersroom.OnMemberMessage+= (byte[] message) =>{ // Deserialize the message using Diarkis.Lib.SyncDataDiarkis.Lib.SyncData syncdata =newDiarkis.Lib.SyncData();syncData.Deserialize(message); // These are the properties from the deserialized messageDictionary<string,object> properties =syncData.Properties;long remotePlayerPositionX =properties.Get("x");long remotePlayerPositionY =properties.Get("y");long remotePlayerVelocity =properties.Get("velocity"); // This is the player ID of the remote playerstring remotePlayerUID =syncdata.UID;}// Properties to be serialized and sentDictionary<string, object> properties =newDictionary<string,object>();properties.Add("x", playerPositionX);properties.Add("y", playerPositionY);properties.Add("velocity", playerVelocity);// Serialize the property data to be sent as a messageDiarkis.Lib.SyncData syncdata =newDiarkis.Lib.SyncData();syncdata.UID= playerUID; // Player IDsyncdata.Properties= properties;syncdata.Serialize();byte[] message =syncdata.Serialized;// Player ID list to send the message toList<string> playerIDs =newList<string>();playerIDs.Add(playerAID);playerIDs.Add(playerBID);playerIDs.Add(playerCID);// If UDP client is used setting this flag to true will make the message delivered as an RUDP messagebool reliable =false;// This is how to send a message to all members in the lobbyroom.MessageTo(playerIDs,room.GetRoomID(), message, reliable);
// Maximum number of members for the game sessionint maxMembers =10;// If true, the room will not be discard when it is emptybool allowEmpty =false;// By setting this flag to false, the room will be emptybool join =false;// This means that the empty room will be available for 5 minutesint ttl =300;// Broadcast message buffering interval in milliseconds to lessen server stressint interval =200;room.Create(maxMembers, allowEmpty, join, ttl, interval);