From f5379df63b312fbdfae6efbac45d065e43324746 Mon Sep 17 00:00:00 2001 From: Redkale <22250530@qq.com> Date: Mon, 22 May 2017 16:47:53 +0800 Subject: [PATCH] --- src/org/redkale/net/Filter.java | 2 +- src/org/redkale/net/http/MultiContext.java | 6 +- src/org/redkale/net/http/WebSocketNode.java | 10 +- .../redkale/net/http/WebSocketService.java | 208 ++++++++++++++++++ 4 files changed, 217 insertions(+), 9 deletions(-) create mode 100644 src/org/redkale/net/http/WebSocketService.java diff --git a/src/org/redkale/net/Filter.java b/src/org/redkale/net/Filter.java index 940f3ec2a..96a22c26a 100644 --- a/src/org/redkale/net/Filter.java +++ b/src/org/redkale/net/Filter.java @@ -41,7 +41,7 @@ public abstract class Filter, P extends /** * 值越小越靠前执行 * - * @return + * @return int */ public int getIndex() { return 0; diff --git a/src/org/redkale/net/http/MultiContext.java b/src/org/redkale/net/http/MultiContext.java index 194a45596..ffa3a192e 100644 --- a/src/org/redkale/net/http/MultiContext.java +++ b/src/org/redkale/net/http/MultiContext.java @@ -96,7 +96,7 @@ public final class MultiContext { * @param contentTypeReg 可接收的ContentType正则表达式 * * @return 二进制文件 - * @throws IOException + * @throws IOException IOException */ public byte[] partsFirstBytes(final long max, final String filenameReg, final String contentTypeReg) throws IOException { if (!isMultipart()) return null; @@ -118,7 +118,7 @@ public final class MultiContext { * @param contentTypeReg 可接收的ContentType正则表达式 * * @return 文件 - * @throws IOException + * @throws IOException IOException */ public File partsFirstFile(final File home, final long max, final String filenameReg, final String contentTypeReg) throws IOException { if (!isMultipart()) return null; @@ -153,7 +153,7 @@ public final class MultiContext { * @param contentTypeReg 可接收的ContentType正则表达式 * * @return 文件列表 - * @throws IOException + * @throws IOException IOException */ public File[] partsFiles(final File home, final long max, final String filenameReg, final String contentTypeReg) throws IOException { if (!isMultipart()) return null; diff --git a/src/org/redkale/net/http/WebSocketNode.java b/src/org/redkale/net/http/WebSocketNode.java index a50e0fbf4..3660ce5f8 100644 --- a/src/org/redkale/net/http/WebSocketNode.java +++ b/src/org/redkale/net/http/WebSocketNode.java @@ -83,10 +83,10 @@ public abstract class WebSocketNode { * 获取目标地址
* 该方法仅供内部调用 * - * @param targetAddress - * @param groupid + * @param targetAddress InetSocketAddress + * @param groupid Serializable * - * @return + * @return 客户端地址列表 */ protected CompletableFuture> remoteWebSocketAddresses(@RpcTargetAddress InetSocketAddress targetAddress, Serializable groupid) { if (remoteNode == null) return CompletableFuture.completedFuture(null); @@ -102,7 +102,7 @@ public abstract class WebSocketNode { * 获取用户在线的SNCP节点地址列表,不是分布式则返回元素数量为1,且元素值为null的列表
* InetSocketAddress 为 SNCP节点地址 * - * @param groupid groupid + * @param groupid Serializable * * @return 地址列表 */ @@ -118,7 +118,7 @@ public abstract class WebSocketNode { * Map.key 为 SNCP节点地址, 含值为null的key表示没有分布式 * Map.value 为 用户客户端的IP * - * @param groupid groupid + * @param groupid Serializable * * @return 地址集合 */ diff --git a/src/org/redkale/net/http/WebSocketService.java b/src/org/redkale/net/http/WebSocketService.java new file mode 100644 index 000000000..c66b59a4f --- /dev/null +++ b/src/org/redkale/net/http/WebSocketService.java @@ -0,0 +1,208 @@ +/* + * 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.net.http; + +import java.lang.annotation.*; +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * 与RestService结合使用 + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ +public interface WebSocketService { + + /** + * 标记在WebSocketService的消息接收方法上 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({METHOD}) + @Retention(RUNTIME) + public @interface RestOnMessage { + + String comment() default ""; //备注描述 + } + + /** + * 标记在WebSocketService的方法上 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({METHOD}) + @Retention(RUNTIME) + public @interface RestOnOpen { + + String comment() default ""; //备注描述 + } + + /** + * 标记在WebSocketService的方法上
+ * 方法的返回值必须是CompletableFuture<Serializable>, 且方法没有参数 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({METHOD}) + @Retention(RUNTIME) + public @interface RestCreateGroup { + + String comment() default ""; //备注描述 + } + + /** + * 标记在WebSocketService的方法上 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({METHOD}) + @Retention(RUNTIME) + public @interface RestOnConnected { + + String comment() default ""; //备注描述 + } + + /** + * 标记在WebSocketService的方法上 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({METHOD}) + @Retention(RUNTIME) + public @interface RestOnClose { + + String comment() default ""; //备注描述 + } + + /** + * 标记在WebSocketService的方法上 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({METHOD}) + @Retention(RUNTIME) + public @interface RestOnPing { + + String comment() default ""; //备注描述 + } + + /** + * 标记在WebSocketService的方法上 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({METHOD}) + @Retention(RUNTIME) + public @interface RestOnPong { + + String comment() default ""; //备注描述 + } + + /** + * 标记在WebSocketService的RestOnMessage方法的boolean参数上 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({PARAMETER}) + @Retention(RUNTIME) + public @interface RestMessageLast { + + String comment() default ""; //备注描述 + } + + /** + * 标记在WebSocketService的方法的String参数上 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({PARAMETER}) + @Retention(RUNTIME) + public @interface RestClientAddress { + + String comment() default ""; //备注描述 + } + + /** + * 标记在WebSocketService的RestOnMessage方法的Serializable参数上 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({PARAMETER}) + @Retention(RUNTIME) + public @interface RestGroupid { + + String comment() default ""; //备注描述 + } + + /** + * 标记在WebSocketService的方法的Serializable参数上 + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({PARAMETER}) + @Retention(RUNTIME) + public @interface RestSessionid { + + String comment() default ""; //备注描述 + } +}