diff --git a/JisolGameCocos/assets/resources/prefab/ui/主页/聊天/MainChatItem.prefab b/JisolGameCocos/assets/resources/prefab/ui/主页/聊天/MainChatItem.prefab index 4e91657b..2fe21a0f 100644 --- a/JisolGameCocos/assets/resources/prefab/ui/主页/聊天/MainChatItem.prefab +++ b/JisolGameCocos/assets/resources/prefab/ui/主页/聊天/MainChatItem.prefab @@ -76,13 +76,13 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 720, - "height": 50.4 + "width": 650, + "height": 58.4 }, "_anchorPoint": { "__type__": "cc.Vec2", "x": 0.5, - "y": 0 + "y": 0.5 }, "_id": "" }, @@ -107,16 +107,16 @@ "_dstBlendFactor": 4, "_color": { "__type__": "cc.Color", - "r": 0, - "g": 0, - "b": 0, + "r": 255, + "g": 255, + "b": 255, "a": 255 }, "_string": "ScrollView content01", - "_horizontalAlign": 1, + "_horizontalAlign": 0, "_verticalAlign": 1, - "_actualFontSize": 36, - "_fontSize": 36, + "_actualFontSize": 32, + "_fontSize": 32, "_fontFamily": "Arial", "_lineHeight": 40, "_overflow": 3, @@ -125,7 +125,7 @@ "_isSystemFontUsed": true, "_spacingX": 0, "_isItalic": false, - "_isBold": false, + "_isBold": true, "_isUnderline": false, "_underlineHeight": 2, "_cacheMode": 0, @@ -136,7 +136,7 @@ "fileId": "7ahEvd3z5N4ruHsPPLIdmV" }, { - "__type__": "cc.Widget", + "__type__": "cc.LabelOutline", "_name": "", "_objFlags": 0, "__editorExtras__": {}, @@ -147,29 +147,19 @@ "__prefab": { "__id__": 7 }, - "_alignFlags": 40, - "_target": null, - "_left": 0, - "_right": 0, - "_top": 0, - "_bottom": 0, - "_horizontalCenter": 0, - "_verticalCenter": 0, - "_isAbsLeft": true, - "_isAbsRight": true, - "_isAbsTop": true, - "_isAbsBottom": true, - "_isAbsHorizontalCenter": true, - "_isAbsVerticalCenter": true, - "_originalWidth": 335.53125, - "_originalHeight": 0, - "_alignMode": 2, - "_lockFlags": 0, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_width": 4, "_id": "" }, { "__type__": "cc.CompPrefabInfo", - "fileId": "61ikNaw6BJr7IaFbNvdfj8" + "fileId": "6cvihYfrtARaa4Y/2l5fPU" }, { "__type__": "cc.PrefabInfo", diff --git a/JisolGameCocos/assets/resources/prefab/ui/主页/聊天/MainChatView.prefab b/JisolGameCocos/assets/resources/prefab/ui/主页/聊天/MainChatView.prefab index ebffcaaf..4385b944 100644 --- a/JisolGameCocos/assets/resources/prefab/ui/主页/聊天/MainChatView.prefab +++ b/JisolGameCocos/assets/resources/prefab/ui/主页/聊天/MainChatView.prefab @@ -956,7 +956,7 @@ "value": { "__type__": "cc.Vec3", "x": 0, - "y": 151.2, + "y": 204.4, "z": 0 } }, @@ -1071,7 +1071,7 @@ "value": { "__type__": "cc.Vec3", "x": 0, - "y": 100.79999999999998, + "y": 146.00000000000003, "z": 0 } }, @@ -1202,7 +1202,7 @@ "value": { "__type__": "cc.Vec3", "x": 0, - "y": 50.399999999999984, + "y": 87.60000000000002, "z": 0 } }, @@ -1333,7 +1333,7 @@ "value": { "__type__": "cc.Vec3", "x": 0, - "y": -1.4210854715202004e-14, + "y": 29.20000000000002, "z": 0 } }, @@ -1398,8 +1398,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 720, - "height": 201.6 + "width": 650, + "height": 233.6 }, "_anchorPoint": { "__type__": "cc.Vec2", diff --git a/JisolGameCocos/assets/script/App.ts b/JisolGameCocos/assets/script/App.ts index 89b8e661..2081583d 100644 --- a/JisolGameCocos/assets/script/App.ts +++ b/JisolGameCocos/assets/script/App.ts @@ -28,14 +28,14 @@ import AppAction from "./AppAction"; import { Asset } from "cc"; import { Component } from "cc"; -// let APIPath = `http://localhost:8080` -// let WsPath = `ws://localhost:8080/websocket` +let APIPath = `http://localhost:8080` +let WsPath = `ws://localhost:8080/websocket` // let APIPath = `http://192.168.1.23:8080` // let WsPath = `ws://192.168.1.23:8080/websocket` // let APIPath = `http://192.168.0.115:8080` // let WsPath = `ws://192.168.0.115:8080/websocket` -let APIPath = `https://api.pet.jisol.cn` -let WsPath = `wss://api.pet.jisol.cn/websocket` +// let APIPath = `https://api.pet.jisol.cn` +// let WsPath = `wss://api.pet.jisol.cn/websocket` //重写UI class JNGLayer extends JNLayer{ diff --git a/JisolGameCocos/assets/script/consts/GActionType.ts b/JisolGameCocos/assets/script/consts/GActionType.ts index 1b81bae7..790d997a 100644 --- a/JisolGameCocos/assets/script/consts/GActionType.ts +++ b/JisolGameCocos/assets/script/consts/GActionType.ts @@ -1,11 +1,16 @@ export interface GUIChatMessage{ message:string; } +export interface GUIChatMessageDTO{ + message:GUIChatMessage; + playerName:string; + playerId:number; +} export enum GActionType { - GUIChatMessage = "GUIChatMessage",//聊天信息 - + GUIChatMessage = "GUIChatMessage",//聊天信息发送 + GUIChatMessageDTO = "GUIChatMessageDTO",//聊天信息接受 /*************** 游戏模式 : 无尽模式(OnHook) **************/ GOnHookPet = "GOnHookPet", //野怪 diff --git a/JisolGameCocos/assets/script/data/ChatData.ts b/JisolGameCocos/assets/script/data/ChatData.ts index a8aaf070..736a2aaf 100644 --- a/JisolGameCocos/assets/script/data/ChatData.ts +++ b/JisolGameCocos/assets/script/data/ChatData.ts @@ -1,7 +1,7 @@ import Singleton from "../../../extensions/ngame/assets/ngame/util/Singleton"; import { app } from "../App"; import { GAction } from "../consts/GAction"; -import { GActionType, GUIChatMessage } from "../consts/GActionType"; +import { GActionType, GUIChatMessage, GUIChatMessageDTO } from "../consts/GActionType"; import BaseData from "./BaseData"; //聊天数据 @@ -10,18 +10,18 @@ export default class ChatData extends BaseData{ static Event = "ChatData_Event_Message"; //世界消息列表 - datas:string[] = []; + datas:GUIChatMessageDTO[] = []; onInit() { //监听聊天消息 - app.socket.on(GAction.CHAT_RECEIVE_MESSAGE,this.onChatReceiveMessage,this,GActionType.GUIChatMessage); + app.socket.on(GAction.CHAT_RECEIVE_MESSAGE,this.onChatReceiveMessage,this,GActionType.GUIChatMessageDTO); } //接受聊天消息 - onChatReceiveMessage(info:GUIChatMessage){ + onChatReceiveMessage(info:GUIChatMessageDTO){ console.log(`ChatData - onChatReceiveMessage`,info.message); - this.datas.push(info.message); + this.datas.push(info); app.event.emit(ChatData.Event,info); } diff --git a/JisolGameCocos/assets/script/ui/Home/Chat/MainChatView.ts b/JisolGameCocos/assets/script/ui/Home/Chat/MainChatView.ts index ed930c2a..ff2c60b7 100644 --- a/JisolGameCocos/assets/script/ui/Home/Chat/MainChatView.ts +++ b/JisolGameCocos/assets/script/ui/Home/Chat/MainChatView.ts @@ -5,7 +5,7 @@ import { instantiate } from 'cc'; import { Label } from 'cc'; import { EditBox } from 'cc'; import { GUI } from '../../UIConfig'; -import { GUIChatMessage } from '../../../consts/GActionType'; +import { GUIChatMessage, GUIChatMessageDTO } from '../../../consts/GActionType'; import { Widget } from 'cc'; import JScrollExceedHide from '../../../../../extensions/ngame/assets/ngame/util/components/JScrollExceedHide'; import { JNGLayerBase } from '../../../components/JNComponent'; @@ -46,9 +46,7 @@ export class MainChatView extends JNGLayerBase { let messages = ChatData.getIns().datas; messages.forEach(message => { - let node = instantiate(this.chatPrefab); - node.getComponent(Label).string = message; - this.content.addChild(node); + this.onMessage(message); }) } @@ -68,11 +66,12 @@ export class MainChatView extends JNGLayerBase { } //接受到消息 - onMessage(info:GUIChatMessage){ + onMessage(info:GUIChatMessageDTO){ //插入数据 let node = instantiate(this.chatPrefab); - node.getComponent(Label).string = info.message; + + node.getComponent(Label).string = `${info.playerName} : ${info.message.message}`; this.content.addChild(node); this.scheduleOnce(() => { this.getComponentInChildren(JScrollExceedHide).onUpdate(); diff --git a/JisolGameCocos/assets/script/ui/Home/MainView.ts b/JisolGameCocos/assets/script/ui/Home/MainView.ts index 5653ce6a..a4249c6f 100644 --- a/JisolGameCocos/assets/script/ui/Home/MainView.ts +++ b/JisolGameCocos/assets/script/ui/Home/MainView.ts @@ -31,7 +31,7 @@ export class MainView extends JNGLayerBase { //发送消息 ChatData.getIns().onSend({ - message:`${PlayerData.getIns().data.playerId} 加入游戏` + message:`加入游戏` }); this.onUpdateView(); diff --git a/JisolGameCocos/extensions/ngame b/JisolGameCocos/extensions/ngame index f147b04d..762bea68 160000 --- a/JisolGameCocos/extensions/ngame +++ b/JisolGameCocos/extensions/ngame @@ -1 +1 @@ -Subproject commit f147b04ddd86f482f842c803027a963a6bcc59de +Subproject commit 762bea687b290ae38580323bdfaec39d537a2668 diff --git a/JisolGameCocos/proto/GUIMessage.proto b/JisolGameCocos/proto/GUIMessage.proto index ffa416a9..09202201 100644 --- a/JisolGameCocos/proto/GUIMessage.proto +++ b/JisolGameCocos/proto/GUIMessage.proto @@ -2,7 +2,13 @@ syntax = "proto3"; option java_package = "cn.jisol.ngame.proto"; -//聊天信息 +//发送聊天信息 message GUIChatMessage { string message = 1; //聊天内容 } + +message GUIChatMessageDTO { + GUIChatMessage message = 1; //聊天内容 + string playerName = 2; + int64 playerId = 3; +} diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/actions/GChatAction.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/actions/GChatAction.java index 9ade27c5..53e377f3 100644 --- a/JisolGameServer/Main/src/main/java/cn/jisol/game/actions/GChatAction.java +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/actions/GChatAction.java @@ -1,5 +1,6 @@ package cn.jisol.game.actions; +import cn.hutool.json.JSONUtil; import cn.jisol.game.network.client.GClient; import cn.jisol.game.proto.GUIMessage; import cn.jisol.ngame.actions.core.NAction; @@ -12,9 +13,17 @@ public class GChatAction { //发送消息 @NActionMethod(GActionEnum.CHAT_MESSAGE) - public static void onChatMessage(GUIMessage.GUIChatMessage message, Map clients){ - clients.values().forEach(client -> { - client.invoke(GActionEnum.CHAT_RECEIVE_MESSAGE,message); + public static void onChatMessage(GUIMessage.GUIChatMessage message, Map clients,GClient client){ + + GUIMessage.GUIChatMessageDTO dto = + GUIMessage.GUIChatMessageDTO.newBuilder() + .setMessage(message) + .setPlayerName(client.player.getPlayerName()) + .setPlayerId(client.player.getPlayerId()) + .build(); + + clients.values().forEach(client1 -> { + client1.invoke(GActionEnum.CHAT_RECEIVE_MESSAGE,dto); }); } diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/actions/onhook/GPVPAction.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/actions/onhook/GPVPAction.java index eea09e16..875ec8fb 100644 --- a/JisolGameServer/Main/src/main/java/cn/jisol/game/actions/onhook/GPVPAction.java +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/actions/onhook/GPVPAction.java @@ -183,10 +183,15 @@ public class GPVPAction { //裁决结束 等待下次裁决 GRefereeAction.addFreeReferee(referee); + GUIMessage.GUIChatMessageDTO message = GUIMessage.GUIChatMessageDTO.newBuilder() + .setMessage(GUIMessage.GUIChatMessage.newBuilder().setMessage("获胜的玩家是:"+info.getWinnerId()).build()) + .setPlayerId(0) + .setPlayerName("系统") + .build(); clients.values().forEach(client -> { client.invoke(GActionEnum.C_MODE_PVP_MESSAGE, GPVPMessage.GPVPText.newBuilder().setText("服务器裁决胜利者"+info.getWinnerId()).build()); - client.invoke(GActionEnum.CHAT_RECEIVE_MESSAGE, GUIMessage.GUIChatMessage.newBuilder().setMessage("获胜的玩家是:"+info.getWinnerId()).build()); + client.invoke(GActionEnum.CHAT_RECEIVE_MESSAGE,message); }); } diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GUIMessage.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GUIMessage.java index 6b4d899d..b881c1ab 100644 --- a/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GUIMessage.java +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GUIMessage.java @@ -40,7 +40,7 @@ public final class GUIMessage { } /** *
-   *聊天信息
+   *发送聊天信息
    * 
* * Protobuf type {@code GUIChatMessage} @@ -330,7 +330,7 @@ public final class GUIMessage { } /** *
-     *聊天信息
+     *发送聊天信息
      * 
* * Protobuf type {@code GUIChatMessage} @@ -628,11 +628,920 @@ public final class GUIMessage { } + public interface GUIChatMessageDTOOrBuilder extends + // @@protoc_insertion_point(interface_extends:GUIChatMessageDTO) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     *聊天内容
+     * 
+ * + * .GUIChatMessage message = 1; + * @return Whether the message field is set. + */ + boolean hasMessage(); + /** + *
+     *聊天内容
+     * 
+ * + * .GUIChatMessage message = 1; + * @return The message. + */ + GUIMessage.GUIChatMessage getMessage(); + /** + *
+     *聊天内容
+     * 
+ * + * .GUIChatMessage message = 1; + */ + GUIMessage.GUIChatMessageOrBuilder getMessageOrBuilder(); + + /** + * string playerName = 2; + * @return The playerName. + */ + java.lang.String getPlayerName(); + /** + * string playerName = 2; + * @return The bytes for playerName. + */ + com.google.protobuf.ByteString + getPlayerNameBytes(); + + /** + * int64 playerId = 3; + * @return The playerId. + */ + long getPlayerId(); + } + /** + * Protobuf type {@code GUIChatMessageDTO} + */ + public static final class GUIChatMessageDTO extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:GUIChatMessageDTO) + GUIChatMessageDTOOrBuilder { + private static final long serialVersionUID = 0L; + // Use GUIChatMessageDTO.newBuilder() to construct. + private GUIChatMessageDTO(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private GUIChatMessageDTO() { + playerName_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new GUIChatMessageDTO(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private GUIChatMessageDTO( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + GUIMessage.GUIChatMessage.Builder subBuilder = null; + if (message_ != null) { + subBuilder = message_.toBuilder(); + } + message_ = input.readMessage(GUIMessage.GUIChatMessage.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(message_); + message_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + playerName_ = s; + break; + } + case 24: { + + playerId_ = input.readInt64(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return GUIMessage.internal_static_GUIChatMessageDTO_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return GUIMessage.internal_static_GUIChatMessageDTO_fieldAccessorTable + .ensureFieldAccessorsInitialized( + GUIMessage.GUIChatMessageDTO.class, GUIMessage.GUIChatMessageDTO.Builder.class); + } + + public static final int MESSAGE_FIELD_NUMBER = 1; + private GUIMessage.GUIChatMessage message_; + /** + *
+     *聊天内容
+     * 
+ * + * .GUIChatMessage message = 1; + * @return Whether the message field is set. + */ + @java.lang.Override + public boolean hasMessage() { + return message_ != null; + } + /** + *
+     *聊天内容
+     * 
+ * + * .GUIChatMessage message = 1; + * @return The message. + */ + @java.lang.Override + public GUIMessage.GUIChatMessage getMessage() { + return message_ == null ? GUIMessage.GUIChatMessage.getDefaultInstance() : message_; + } + /** + *
+     *聊天内容
+     * 
+ * + * .GUIChatMessage message = 1; + */ + @java.lang.Override + public GUIMessage.GUIChatMessageOrBuilder getMessageOrBuilder() { + return getMessage(); + } + + public static final int PLAYERNAME_FIELD_NUMBER = 2; + private volatile java.lang.Object playerName_; + /** + * string playerName = 2; + * @return The playerName. + */ + @java.lang.Override + public java.lang.String getPlayerName() { + java.lang.Object ref = playerName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + playerName_ = s; + return s; + } + } + /** + * string playerName = 2; + * @return The bytes for playerName. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getPlayerNameBytes() { + java.lang.Object ref = playerName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + playerName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PLAYERID_FIELD_NUMBER = 3; + private long playerId_; + /** + * int64 playerId = 3; + * @return The playerId. + */ + @java.lang.Override + public long getPlayerId() { + return playerId_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (message_ != null) { + output.writeMessage(1, getMessage()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(playerName_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, playerName_); + } + if (playerId_ != 0L) { + output.writeInt64(3, playerId_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (message_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getMessage()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(playerName_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, playerName_); + } + if (playerId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, playerId_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof GUIMessage.GUIChatMessageDTO)) { + return super.equals(obj); + } + GUIMessage.GUIChatMessageDTO other = (GUIMessage.GUIChatMessageDTO) obj; + + if (hasMessage() != other.hasMessage()) return false; + if (hasMessage()) { + if (!getMessage() + .equals(other.getMessage())) return false; + } + if (!getPlayerName() + .equals(other.getPlayerName())) return false; + if (getPlayerId() + != other.getPlayerId()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasMessage()) { + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + } + hash = (37 * hash) + PLAYERNAME_FIELD_NUMBER; + hash = (53 * hash) + getPlayerName().hashCode(); + hash = (37 * hash) + PLAYERID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getPlayerId()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static GUIMessage.GUIChatMessageDTO parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GUIMessage.GUIChatMessageDTO parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GUIMessage.GUIChatMessageDTO parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GUIMessage.GUIChatMessageDTO parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GUIMessage.GUIChatMessageDTO parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static GUIMessage.GUIChatMessageDTO parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static GUIMessage.GUIChatMessageDTO parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static GUIMessage.GUIChatMessageDTO parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static GUIMessage.GUIChatMessageDTO parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static GUIMessage.GUIChatMessageDTO parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static GUIMessage.GUIChatMessageDTO parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static GUIMessage.GUIChatMessageDTO parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(GUIMessage.GUIChatMessageDTO prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code GUIChatMessageDTO} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:GUIChatMessageDTO) + GUIMessage.GUIChatMessageDTOOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return GUIMessage.internal_static_GUIChatMessageDTO_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return GUIMessage.internal_static_GUIChatMessageDTO_fieldAccessorTable + .ensureFieldAccessorsInitialized( + GUIMessage.GUIChatMessageDTO.class, GUIMessage.GUIChatMessageDTO.Builder.class); + } + + // Construct using cn.jisol.game.proto.GUIMessage.GUIChatMessageDTO.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (messageBuilder_ == null) { + message_ = null; + } else { + message_ = null; + messageBuilder_ = null; + } + playerName_ = ""; + + playerId_ = 0L; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return GUIMessage.internal_static_GUIChatMessageDTO_descriptor; + } + + @java.lang.Override + public GUIMessage.GUIChatMessageDTO getDefaultInstanceForType() { + return GUIMessage.GUIChatMessageDTO.getDefaultInstance(); + } + + @java.lang.Override + public GUIMessage.GUIChatMessageDTO build() { + GUIMessage.GUIChatMessageDTO result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public GUIMessage.GUIChatMessageDTO buildPartial() { + GUIMessage.GUIChatMessageDTO result = new GUIMessage.GUIChatMessageDTO(this); + if (messageBuilder_ == null) { + result.message_ = message_; + } else { + result.message_ = messageBuilder_.build(); + } + result.playerName_ = playerName_; + result.playerId_ = playerId_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof GUIMessage.GUIChatMessageDTO) { + return mergeFrom((GUIMessage.GUIChatMessageDTO)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(GUIMessage.GUIChatMessageDTO other) { + if (other == GUIMessage.GUIChatMessageDTO.getDefaultInstance()) return this; + if (other.hasMessage()) { + mergeMessage(other.getMessage()); + } + if (!other.getPlayerName().isEmpty()) { + playerName_ = other.playerName_; + onChanged(); + } + if (other.getPlayerId() != 0L) { + setPlayerId(other.getPlayerId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + GUIMessage.GUIChatMessageDTO parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (GUIMessage.GUIChatMessageDTO) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private GUIMessage.GUIChatMessage message_; + private com.google.protobuf.SingleFieldBuilderV3< + GUIMessage.GUIChatMessage, GUIMessage.GUIChatMessage.Builder, GUIMessage.GUIChatMessageOrBuilder> messageBuilder_; + /** + *
+       *聊天内容
+       * 
+ * + * .GUIChatMessage message = 1; + * @return Whether the message field is set. + */ + public boolean hasMessage() { + return messageBuilder_ != null || message_ != null; + } + /** + *
+       *聊天内容
+       * 
+ * + * .GUIChatMessage message = 1; + * @return The message. + */ + public GUIMessage.GUIChatMessage getMessage() { + if (messageBuilder_ == null) { + return message_ == null ? GUIMessage.GUIChatMessage.getDefaultInstance() : message_; + } else { + return messageBuilder_.getMessage(); + } + } + /** + *
+       *聊天内容
+       * 
+ * + * .GUIChatMessage message = 1; + */ + public Builder setMessage(GUIMessage.GUIChatMessage value) { + if (messageBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + message_ = value; + onChanged(); + } else { + messageBuilder_.setMessage(value); + } + + return this; + } + /** + *
+       *聊天内容
+       * 
+ * + * .GUIChatMessage message = 1; + */ + public Builder setMessage( + GUIMessage.GUIChatMessage.Builder builderForValue) { + if (messageBuilder_ == null) { + message_ = builderForValue.build(); + onChanged(); + } else { + messageBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+       *聊天内容
+       * 
+ * + * .GUIChatMessage message = 1; + */ + public Builder mergeMessage(GUIMessage.GUIChatMessage value) { + if (messageBuilder_ == null) { + if (message_ != null) { + message_ = + GUIMessage.GUIChatMessage.newBuilder(message_).mergeFrom(value).buildPartial(); + } else { + message_ = value; + } + onChanged(); + } else { + messageBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+       *聊天内容
+       * 
+ * + * .GUIChatMessage message = 1; + */ + public Builder clearMessage() { + if (messageBuilder_ == null) { + message_ = null; + onChanged(); + } else { + message_ = null; + messageBuilder_ = null; + } + + return this; + } + /** + *
+       *聊天内容
+       * 
+ * + * .GUIChatMessage message = 1; + */ + public GUIMessage.GUIChatMessage.Builder getMessageBuilder() { + + onChanged(); + return getMessageFieldBuilder().getBuilder(); + } + /** + *
+       *聊天内容
+       * 
+ * + * .GUIChatMessage message = 1; + */ + public GUIMessage.GUIChatMessageOrBuilder getMessageOrBuilder() { + if (messageBuilder_ != null) { + return messageBuilder_.getMessageOrBuilder(); + } else { + return message_ == null ? + GUIMessage.GUIChatMessage.getDefaultInstance() : message_; + } + } + /** + *
+       *聊天内容
+       * 
+ * + * .GUIChatMessage message = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + GUIMessage.GUIChatMessage, GUIMessage.GUIChatMessage.Builder, GUIMessage.GUIChatMessageOrBuilder> + getMessageFieldBuilder() { + if (messageBuilder_ == null) { + messageBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + GUIMessage.GUIChatMessage, GUIMessage.GUIChatMessage.Builder, GUIMessage.GUIChatMessageOrBuilder>( + getMessage(), + getParentForChildren(), + isClean()); + message_ = null; + } + return messageBuilder_; + } + + private java.lang.Object playerName_ = ""; + /** + * string playerName = 2; + * @return The playerName. + */ + public java.lang.String getPlayerName() { + java.lang.Object ref = playerName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + playerName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string playerName = 2; + * @return The bytes for playerName. + */ + public com.google.protobuf.ByteString + getPlayerNameBytes() { + java.lang.Object ref = playerName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + playerName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string playerName = 2; + * @param value The playerName to set. + * @return This builder for chaining. + */ + public Builder setPlayerName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + playerName_ = value; + onChanged(); + return this; + } + /** + * string playerName = 2; + * @return This builder for chaining. + */ + public Builder clearPlayerName() { + + playerName_ = getDefaultInstance().getPlayerName(); + onChanged(); + return this; + } + /** + * string playerName = 2; + * @param value The bytes for playerName to set. + * @return This builder for chaining. + */ + public Builder setPlayerNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + playerName_ = value; + onChanged(); + return this; + } + + private long playerId_ ; + /** + * int64 playerId = 3; + * @return The playerId. + */ + @java.lang.Override + public long getPlayerId() { + return playerId_; + } + /** + * int64 playerId = 3; + * @param value The playerId to set. + * @return This builder for chaining. + */ + public Builder setPlayerId(long value) { + + playerId_ = value; + onChanged(); + return this; + } + /** + * int64 playerId = 3; + * @return This builder for chaining. + */ + public Builder clearPlayerId() { + + playerId_ = 0L; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:GUIChatMessageDTO) + } + + // @@protoc_insertion_point(class_scope:GUIChatMessageDTO) + private static final GUIMessage.GUIChatMessageDTO DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new GUIMessage.GUIChatMessageDTO(); + } + + public static GUIMessage.GUIChatMessageDTO getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GUIChatMessageDTO parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new GUIChatMessageDTO(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public GUIMessage.GUIChatMessageDTO getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + private static final com.google.protobuf.Descriptors.Descriptor internal_static_GUIChatMessage_descriptor; private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_GUIChatMessage_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_GUIChatMessageDTO_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_GUIChatMessageDTO_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -643,8 +1552,10 @@ public final class GUIMessage { static { java.lang.String[] descriptorData = { "\n\020GUIMessage.proto\"!\n\016GUIChatMessage\022\017\n\007" + - "message\030\001 \001(\tB\026\n\024cn.jisol.ngame.protob\006p" + - "roto3" + "message\030\001 \001(\t\"[\n\021GUIChatMessageDTO\022 \n\007me" + + "ssage\030\001 \001(\0132\017.GUIChatMessage\022\022\n\nplayerNa" + + "me\030\002 \001(\t\022\020\n\010playerId\030\003 \001(\003B\026\n\024cn.jisol.n" + + "game.protob\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -656,6 +1567,12 @@ public final class GUIMessage { com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_GUIChatMessage_descriptor, new java.lang.String[] { "Message", }); + internal_static_GUIChatMessageDTO_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_GUIChatMessageDTO_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_GUIChatMessageDTO_descriptor, + new java.lang.String[] { "Message", "PlayerName", "PlayerId", }); } // @@protoc_insertion_point(outer_class_scope) diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GUIMessage.proto b/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GUIMessage.proto index ffa416a9..09202201 100644 --- a/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GUIMessage.proto +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GUIMessage.proto @@ -2,7 +2,13 @@ syntax = "proto3"; option java_package = "cn.jisol.ngame.proto"; -//聊天信息 +//发送聊天信息 message GUIChatMessage { string message = 1; //聊天内容 } + +message GUIChatMessageDTO { + GUIChatMessage message = 1; //聊天内容 + string playerName = 2; + int64 playerId = 3; +} diff --git a/JisolGameServer/Main/src/main/resources/application.yml b/JisolGameServer/Main/src/main/resources/application.yml index 26fc9772..c9a856f9 100644 --- a/JisolGameServer/Main/src/main/resources/application.yml +++ b/JisolGameServer/Main/src/main/resources/application.yml @@ -4,8 +4,8 @@ spring: datasource: username: pet_jisol_cn password: sThsBwjfDcaw2wJR -# url: jdbc:mysql://kyu.jisol.cn:3306/pet_jisol_cn?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&allowMultiQueries=true - url: jdbc:mysql://localhost:3306/pet_jisol_cn?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&allowMultiQueries=true + url: jdbc:mysql://kyu.jisol.cn:3306/pet_jisol_cn?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&allowMultiQueries=true +# url: jdbc:mysql://localhost:3306/pet_jisol_cn?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&allowMultiQueries=true driver-class-name: com.mysql.cj.jdbc.Driver jackson: serialization: