Redkale 2.6.0 结束

This commit is contained in:
Redkale
2021-12-01 09:52:52 +08:00
parent f0ac042b3c
commit 6e21fe56e9
50 changed files with 1457 additions and 413 deletions

View File

@@ -0,0 +1,57 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.convert;
import java.util.*;
import org.junit.jupiter.api.Test;
import org.redkale.convert.json.JsonConvert;
/**
*
* @author zhangjx
*/
public class DyncJsonTest {
public static void main(String[] args) throws Throwable {
new DyncJsonTest().run();
}
@Test
public void run() throws Exception {
SimpleDyncBean bean = new SimpleDyncBean();
bean.name = "haha";
System.out.println(JsonConvert.root().convertTo(bean));
SimpleDyncBean2 bean2 = new SimpleDyncBean2();
bean2.name = "haha";
System.out.println(JsonConvert.root().convertTo(bean2));
SimpleDyncBean3 bean3 = new SimpleDyncBean3();
bean3.name = "haha";
System.out.println(JsonConvert.root().convertTo(bean3));
}
public static class SimpleDyncBean {
public String name;
public List<SimpleDyncBean> beans;
}
public static class SimpleDyncBean2 {
public String name;
public SimpleDyncBean2 bean2;
}
public static class SimpleDyncBean3 {
public String name;
public Map<String, SimpleDyncBean3> beanmap;
}
}

View File

@@ -46,4 +46,10 @@ public class ChatService implements Service {
public void chatMessage(ChatMessage message) {
wsnode.broadcastMessage(message);
}
@Comment("其他操作")
public void other(int roomid, String name) {
System.out.println("其他操作: roomid: " + roomid + ", name: " + name);
}
}

View File

@@ -91,4 +91,21 @@ public class ChatWebSocket extends WebSocket<Integer, Object> {
service.joinRoom(getUserid(), roomid);
}
/**
* 浏览器WebSocket请求
* <pre>
* websocket.send(JSON.stringify({
* roomid: 10212
* name: "haha"
* }));
* </pre>
*
* @param roomid 参数1
* @param name 参数2
*/
@RestOnMessage(name = "*") //*为特殊值表示参数中不包含方法名
public void other(int roomid, String name) {
service.other(roomid, name);
}
}

View File

@@ -31,7 +31,7 @@ public final class _DyncChatWebSocketServlet extends WebSocketServlet {
public _DyncChatWebSocketServlet() {
super();
this.messageTextType = _DyncChatWebSocketMessage.class;
this.messageRestType = _DyncChatWebSocketMessage.class;
}
@Override
@@ -52,12 +52,48 @@ public final class _DyncChatWebSocketServlet extends WebSocketServlet {
}
}
public static class _DyncChatWebSocketMessage {
public static class _DyncChatWebSocketMessage implements WebSocketParam, Runnable {
public _DyncChatWebSocketMessage_sendmessagee_00 sendmessage;
public _DyncChatWebSocketMessage_joinroom_01 joinroom;
@ConvertDisabled
public _DyncChatWebSocket _redkale_websocket;
public int roomid;
public String name;
@Override
public String[] getNames() {
return new String[]{"roomid", "name"};
}
@Override
public <T> T getValue(String name) {
if ("roomid".equals(name)) return (T) (Integer) roomid;
if ("name".equals(name)) return (T) (String) name;
return null;
}
@Override
public Annotation[] getAnnotations() {
Annotation[] annotations = _redkale_annotations.get("org/redkale/test/wsdync/_DyncChatWebSocketServlet$_DyncChatWebSocketMessage");
if (annotations == null) return new Annotation[0];
return Arrays.copyOf(annotations, annotations.length);
}
public void execute(_DyncChatWebSocket websocket) {
this._redkale_websocket = websocket;
websocket.preOnMessage("*", this, this);
}
@Override
public void run() {
_redkale_websocket.other(this.roomid, this.name);
}
@Override
public String toString() {
return JsonConvert.root().convertTo(this);
@@ -163,6 +199,7 @@ public final class _DyncChatWebSocketServlet extends WebSocketServlet {
message.joinroom.execute(websocket);
return;
}
message.execute(websocket);
}
}