在匹配成功,创建房间后发送地图信息
parent
c62efe0565
commit
547c632e81
|
|
@ -136,26 +136,9 @@ public class Room {
|
|||
RoomFightProto.RoomGameStartResponse.Builder builder = RoomFightProto.RoomGameStartResponse.newBuilder();
|
||||
builder.setClientTimestamp(request.getClientTimestamp());
|
||||
builder.setServerTimestamp(System.currentTimeMillis());
|
||||
builder.setMapId(mapId);
|
||||
|
||||
CommonProto.Cell.Builder cellBuilder = CommonProto.Cell.newBuilder();
|
||||
builder.addMapList(cellBuilder.build());
|
||||
|
||||
RoomFightProto.AgentInfo.Builder selfBuilder = RoomFightProto.AgentInfo.newBuilder();
|
||||
builder.setAgentInfo(selfBuilder.build());
|
||||
|
||||
for(int i=0; i<roomPlayerInfos.length; i++){
|
||||
if(roomPlayerInfos[i] == null){
|
||||
continue;
|
||||
}
|
||||
RoomFightProto.AgentInfo.Builder otherBuilder = RoomFightProto.AgentInfo.newBuilder();
|
||||
builder.addOtherAgentInfos(otherBuilder.build());
|
||||
}
|
||||
builder.setLeftTime(Room.MAX_GAME_LENGTH);
|
||||
|
||||
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
||||
builder.setTemporaryItems(dropBuilder.build());
|
||||
|
||||
MessageUtil.sendMessage(iSession, 0, responseMsgId, builder.build(), true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.ljsd.jieling.logic.room;
|
|||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.RoomFightProto;
|
||||
import com.ljsd.jieling.protocols.RoomProto;
|
||||
|
|
@ -102,14 +103,20 @@ public class RoomManager {
|
|||
Room room = new Room(roomId, roomMatchRequest.getType(), playerArray);
|
||||
roomMap.put(roomId, room);
|
||||
|
||||
List<CommonProto.Cell> cells = new ArrayList<>();
|
||||
|
||||
List<RoomProto.AgentInfo> agentInfoList = new ArrayList<>();
|
||||
|
||||
for(int i=0; i<playerArray.length; i++)
|
||||
{
|
||||
User user = UserManager.getUserInMem(playerArray[i]);
|
||||
user.getRoomInfo().setMatching(false);
|
||||
user.getRoomInfo().setRoomId(roomId);
|
||||
MessageUtil.sendRoomMatchSuccessIndication(playerArray[i], room.getType(), roomId);
|
||||
RoomProto.AgentInfo.Builder agentInfoBuilder = RoomProto.AgentInfo.newBuilder();
|
||||
agentInfoList.add(agentInfoBuilder.build());
|
||||
}
|
||||
|
||||
MessageUtil.sendRoomMatchSuccessIndication(playerArray, room.getType(), roomId, 1, cells, agentInfoList);
|
||||
return room;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.google.protobuf.GeneratedMessage;
|
|||
import com.googlecode.protobuf.format.JsonFormat;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.room.Room;
|
||||
import com.ljsd.jieling.netty.PackageConstant;
|
||||
import com.ljsd.jieling.netty.cocdex.Tea;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
|
|
@ -50,6 +51,11 @@ public class MessageUtil {
|
|||
return Tea.encrypt2(bytes, secretKey);
|
||||
}
|
||||
|
||||
public static void sendMessage(int[] uids, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
|
||||
for(int i=0; i<uids.length; i++){
|
||||
sendMessage(uids[i], result, msgId, generatedMessage, flush);
|
||||
}
|
||||
}
|
||||
public static void sendMessage(int uid, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(uid);
|
||||
sendMessage(sessionByUid, result, msgId, generatedMessage, flush);
|
||||
|
|
@ -177,13 +183,13 @@ public class MessageUtil {
|
|||
// sendMessage(session, uid, (int) index, 0, msgId, generatedMessage, true);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 对所有在线用户发送通知
|
||||
*
|
||||
* @param msgId
|
||||
* @param generatedMessage
|
||||
* @throws Exception
|
||||
*/
|
||||
// /**
|
||||
// * 对所有在线用户发送通知
|
||||
// *
|
||||
// * @param msgId
|
||||
// * @param generatedMessage
|
||||
// * @throws Exception
|
||||
// */
|
||||
// public static void sendAllIndication(int msgId, GeneratedMessage generatedMessage) throws Exception {
|
||||
// Map<Integer, Session> sessionMap = OnlineUserManager.sessionMap;
|
||||
// Msg msg = new Msg();
|
||||
|
|
@ -202,11 +208,18 @@ public class MessageUtil {
|
|||
sendMessage(session, 1, responseMsgId, builder.build(), true);
|
||||
}
|
||||
|
||||
public static void sendRoomMatchSuccessIndication(int uid, int type, int roomId) {
|
||||
public static void sendRoomMatchSuccessIndication(int[] uids, int type, int roomId, int mapId,
|
||||
List<CommonProto.Cell> cellList, List<RoomProto.AgentInfo> agentInfoList) {
|
||||
RoomProto.RoomMatchSuccessIndication.Builder builder = RoomProto.RoomMatchSuccessIndication.newBuilder();
|
||||
builder.setRoomId(roomId);
|
||||
builder.setType(type);
|
||||
sendMessage(uid, 1, MessageTypeProto.MessageType.ROOM_MATCH_SUCCESS_INDICATION_VALUE, builder.build(), true);
|
||||
builder.setMapId(mapId);
|
||||
builder.addAllMapList(cellList);
|
||||
builder.addAllAgentInfos(agentInfoList);
|
||||
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
||||
builder.setTemporaryItems(dropBuilder.build());
|
||||
|
||||
sendMessage(uids, 1, MessageTypeProto.MessageType.ROOM_MATCH_SUCCESS_INDICATION_VALUE, builder.build(), true);
|
||||
}
|
||||
|
||||
public static void sendRoomCancelMatchResponse(ISession session, int responseMsgId, int type, boolean result) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue