├── docs ├── proto.png ├── architecture.png ├── pb │ ├── README.md │ ├── auth.proto │ └── message.proto └── websocket │ ├── demo.html │ └── js │ ├── long.min.js │ ├── bytebuffer.min.js │ └── protobuf.min.js ├── comet ├── src │ ├── main │ │ ├── java │ │ │ └── wiki │ │ │ │ └── tony │ │ │ │ └── chat │ │ │ │ └── comet │ │ │ │ ├── exception │ │ │ │ ├── NotAuthException.java │ │ │ │ └── ChatException.java │ │ │ │ ├── ChatServer.java │ │ │ │ ├── bean │ │ │ │ └── Constants.java │ │ │ │ ├── operation │ │ │ │ ├── Operation.java │ │ │ │ ├── HeartbeatOperation.java │ │ │ │ ├── AbstractOperation.java │ │ │ │ ├── MessageOperation.java │ │ │ │ └── AuthOperation.java │ │ │ │ ├── initializer │ │ │ │ ├── TcpServerInitializer.java │ │ │ │ └── WebSocketServerInitializer.java │ │ │ │ ├── ChatOperation.java │ │ │ │ ├── ChatApplication.java │ │ │ │ ├── server │ │ │ │ ├── TcpChatServer.java │ │ │ │ └── WebSocketChatServer.java │ │ │ │ ├── codec │ │ │ │ ├── TcpProtoCodec.java │ │ │ │ └── WebSocketProtoCodec.java │ │ │ │ └── handler │ │ │ │ └── ChatServerHandler.java │ │ └── resources │ │ │ ├── application.yml │ │ │ └── dubbo-consumer.xml │ └── test │ │ └── java │ │ └── wiki │ │ └── tony │ │ └── chat │ │ └── comet │ │ └── client │ │ └── ChatClient.java └── pom.xml ├── base ├── src │ └── main │ │ └── java │ │ └── wiki │ │ └── tony │ │ └── chat │ │ └── base │ │ ├── service │ │ ├── MsgService.java │ │ └── AuthService.java │ │ ├── exception │ │ └── ConnectionAuthException.java │ │ ├── bean │ │ ├── Constants.java │ │ ├── AuthToken.java │ │ ├── Message.java │ │ └── Proto.java │ │ └── pb │ │ └── Auth.java └── pom.xml ├── .gitignore ├── logic ├── src │ └── main │ │ ├── resources │ │ ├── application.yml │ │ └── dubbo-provider.xml │ │ └── java │ │ └── wiki │ │ └── tony │ │ └── chat │ │ └── logic │ │ ├── LogicApplication.java │ │ ├── config │ │ └── CachingConfig.java │ │ └── service │ │ ├── MsgServiceImpl.java │ │ └── AuthServiceImpl.java └── pom.xml ├── web └── pom.xml ├── README.md └── pom.xml /docs/proto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonybase/netty-chat/HEAD/docs/proto.png -------------------------------------------------------------------------------- /docs/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonybase/netty-chat/HEAD/docs/architecture.png -------------------------------------------------------------------------------- /docs/pb/README.md: -------------------------------------------------------------------------------- 1 | ### Install 2 | 3 | https://github.com/google/protobuf/releases 4 | 5 | ### Build 6 | 7 | protoc --java_out=../../base/src/main/java *.proto 8 | 9 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/exception/NotAuthException.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.exception; 2 | 3 | /** 4 | * 认证异常类 5 | */ 6 | public class NotAuthException extends ChatException { 7 | public NotAuthException() { 8 | super("未登录认证"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/ChatServer.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet; 2 | 3 | /** 4 | * 聊天服务接口 5 | */ 6 | public interface ChatServer { 7 | 8 | void start() throws Exception; 9 | 10 | void restart() throws Exception; 11 | 12 | void shutdown(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/bean/Constants.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.bean; 2 | 3 | import io.netty.util.AttributeKey; 4 | import wiki.tony.chat.base.bean.AuthToken; 5 | 6 | /** 7 | * 常量 8 | */ 9 | public class Constants { 10 | 11 | public static final AttributeKey KEY_USER_ID = AttributeKey.valueOf("key"); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/operation/Operation.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.operation; 2 | 3 | import io.netty.channel.Channel; 4 | import wiki.tony.chat.base.bean.Proto; 5 | 6 | /** 7 | * 操作类 8 | */ 9 | public interface Operation { 10 | 11 | Integer op(); 12 | 13 | void action(Channel ch, Proto proto) throws Exception; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /docs/pb/auth.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "wiki.tony.chat.base.pb"; 4 | option java_outer_classname = "Auth"; 5 | option optimize_for = LITE_RUNTIME; 6 | 7 | message AuthReq { 8 | uint32 uid = 1; 9 | string token = 2; 10 | } 11 | 12 | message AuthResp { 13 | uint32 uid = 1; 14 | uint32 code = 2; 15 | string message = 3; 16 | } -------------------------------------------------------------------------------- /base/src/main/java/wiki/tony/chat/base/service/MsgService.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.base.service; 2 | 3 | import wiki.tony.chat.base.bean.Proto; 4 | 5 | /** 6 | * 消息处理接口 7 | */ 8 | public interface MsgService { 9 | 10 | /** 11 | * 接收消息 12 | * 13 | * @param proto 协议 14 | * @return 是否处理成功 15 | */ 16 | boolean receive(Proto proto); 17 | } 18 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/exception/ChatException.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.exception; 2 | 3 | /** 4 | * 聊天异常类 5 | */ 6 | public abstract class ChatException extends Exception { 7 | 8 | public ChatException(String message) { 9 | super(message); 10 | } 11 | 12 | public ChatException(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | kdiff3 ignore 2 | *.orig 3 | 4 | # maven ignore 5 | target/ 6 | 7 | # eclipse ignore 8 | .settings/ 9 | .project 10 | .classpath 11 | 12 | # idea ignore 13 | .idea/ 14 | *.ipr 15 | *.iml 16 | *.iws 17 | 18 | # temp ignore 19 | *.log 20 | *.cache 21 | *.diff 22 | *.patch 23 | *.tmp 24 | 25 | # system ignore 26 | .DS_Store 27 | Thumbs.db 28 | 29 | # package ignore (optional) 30 | # *.jar 31 | # *.war 32 | # *.zip 33 | # *.tar 34 | # *.tar.gz -------------------------------------------------------------------------------- /base/src/main/java/wiki/tony/chat/base/exception/ConnectionAuthException.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.base.exception; 2 | 3 | /** 4 | * 连接身份验证异常类 5 | */ 6 | public class ConnectionAuthException extends Exception { 7 | 8 | /** 9 | * 连接身份验证异常 10 | * 11 | * @param message 异常消息 12 | * @param cause 完整异常 13 | */ 14 | public ConnectionAuthException(String message, Throwable cause) { 15 | super(message, cause); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /comet/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | id: 1 3 | tcp: 4 | port: 9090 5 | websocket: 6 | port: 8090 7 | logging: 8 | level: 9 | wiki.tony: DEBUG 10 | dubbo: 11 | application: 12 | name: dubbo-consumer 13 | registry: 14 | protocol: zookeeper 15 | address: localhost 16 | port: 2181 17 | reference-1: 18 | interface: wiki.tony.chat.base.service.MsgService 19 | reference-2: 20 | interface: wiki.tony.chat.base.service.AuthService -------------------------------------------------------------------------------- /base/src/main/java/wiki/tony/chat/base/bean/Constants.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.base.bean; 2 | 3 | /** 4 | * Created by tony on 9/10/16. 5 | */ 6 | public class Constants { 7 | 8 | public static final int OP_AUTH = 1; 9 | public static final int OP_AUTH_REPLY = 2; 10 | 11 | public static final int OP_HEARTBEAT = 3; 12 | public static final int OP_HEARTBEAT_REPLY = 4; 13 | 14 | public static final int OP_MESSAGE = 5; 15 | public static final int OP_MESSAGE_REPLY = 6; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /logic/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | wiki.tony: DEBUG 4 | dubbo: 5 | application: 6 | name: dubbo-provider 7 | annotation: 8 | package: wiki.tony.chat.logic.service.* 9 | registry: 10 | protocol: zookeeper 11 | address: 127.0.0.1 12 | port: 2181 13 | check: false 14 | subscribe: false 15 | service-1: 16 | interface: wiki.tony.chat.base.service.MsgService 17 | ref: msgService 18 | service-2: 19 | interface: wiki.tony.chat.base.service.AuthService 20 | ref: authService -------------------------------------------------------------------------------- /web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | netty-chat 7 | wiki.tony.chat 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | netty-chat-web 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/pb/message.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "wiki.tony.chat.base.pb"; 4 | option java_outer_classname = "Message"; 5 | option optimize_for = LITE_RUNTIME; 6 | 7 | enum MsgType { 8 | SINGLE_TEXT = 0; 9 | SINGLE_AUDIO = 1; 10 | GROUP_TEXT = 2; 11 | GROUP_AUDIO = 3; 12 | } 13 | 14 | message MsgData { 15 | uint32 to = 1; 16 | uint32 from = 2; 17 | uint32 ctime = 3; 18 | MsgType type = 4; 19 | bytes data = 5; 20 | } 21 | 22 | message MsgNotify { 23 | uint32 seq = 1; 24 | } 25 | 26 | message MsgSync { 27 | uint32 seq = 1; 28 | } 29 | 30 | message MsgSyncData { 31 | repeated MsgData messages = 1; 32 | } 33 | -------------------------------------------------------------------------------- /base/src/main/java/wiki/tony/chat/base/service/AuthService.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.base.service; 2 | 3 | import wiki.tony.chat.base.bean.Proto; 4 | import wiki.tony.chat.base.exception.ConnectionAuthException; 5 | 6 | /** 7 | * 用户验证接口 8 | */ 9 | public interface AuthService { 10 | 11 | /** 12 | * 用户身份验证 13 | * 14 | * @param serverId 服务ID 15 | * @param proto 协议 16 | * @return 用户KEY 17 | * @throws ConnectionAuthException 验证异常 18 | */ 19 | String auth(int serverId, Proto proto) throws ConnectionAuthException; 20 | 21 | /** 22 | * 用户推出 23 | * 24 | * @param serverId 服务ID 25 | * @param key 用户KEY 26 | * @return 是否成功 27 | */ 28 | boolean quit(int serverId, String key); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/operation/HeartbeatOperation.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.operation; 2 | 3 | import io.netty.channel.Channel; 4 | import org.springframework.stereotype.Component; 5 | import wiki.tony.chat.base.bean.Constants; 6 | import wiki.tony.chat.base.bean.Proto; 7 | 8 | /** 9 | * 心跳 10 | */ 11 | @Component 12 | public class HeartbeatOperation extends AbstractOperation { 13 | 14 | @Override 15 | public Integer op() { 16 | return Constants.OP_HEARTBEAT; 17 | } 18 | 19 | @Override 20 | public void action(Channel ch, Proto proto) throws Exception { 21 | // write heartbeat reply 22 | proto.setOperation(Constants.OP_HEARTBEAT_REPLY); 23 | proto.setBody(null); 24 | ch.writeAndFlush(proto); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/operation/AbstractOperation.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.operation; 2 | 3 | import io.netty.channel.Channel; 4 | import wiki.tony.chat.base.bean.AuthToken; 5 | import wiki.tony.chat.comet.bean.Constants; 6 | import wiki.tony.chat.comet.exception.NotAuthException; 7 | 8 | /** 9 | * 操作类抽象方法 10 | */ 11 | public abstract class AbstractOperation implements Operation { 12 | 13 | protected String getKey(Channel ch) { 14 | return ch.attr(Constants.KEY_USER_ID).get(); 15 | } 16 | 17 | protected void setKey(Channel ch, String key) { 18 | ch.attr(Constants.KEY_USER_ID).set(key); 19 | } 20 | 21 | protected void checkAuth(Channel ch) throws NotAuthException { 22 | if (!ch.hasAttr(Constants.KEY_USER_ID)) { 23 | throw new NotAuthException(); 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/initializer/TcpServerInitializer.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.initializer; 2 | 3 | import io.netty.channel.ChannelInitializer; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | import wiki.tony.chat.comet.codec.TcpProtoCodec; 7 | import wiki.tony.chat.comet.handler.ChatServerHandler; 8 | 9 | /** 10 | * TCP服务初始化类 11 | */ 12 | @Component 13 | public class TcpServerInitializer extends ChannelInitializer { 14 | 15 | @Autowired 16 | private TcpProtoCodec protoCodec; 17 | @Autowired 18 | private ChatServerHandler serverHandler; 19 | 20 | @Override 21 | protected void initChannel(io.netty.channel.Channel ch) throws Exception { 22 | ch.pipeline().addLast(protoCodec); 23 | ch.pipeline().addLast(serverHandler); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /base/src/main/java/wiki/tony/chat/base/bean/AuthToken.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.base.bean; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | /** 6 | * 用户验证类 7 | */ 8 | public class AuthToken { 9 | 10 | @JsonProperty("user_id") 11 | private long userId; 12 | @JsonProperty("token") 13 | private String token; 14 | 15 | public long getUserId() { 16 | return userId; 17 | } 18 | 19 | public void setUserId(long userId) { 20 | this.userId = userId; 21 | } 22 | 23 | public String getToken() { 24 | return token; 25 | } 26 | 27 | public void setToken(String token) { 28 | this.token = token; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "AuthToken{" + 34 | "userId=" + userId + 35 | ", token=" + token + 36 | '}'; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /base/src/main/java/wiki/tony/chat/base/bean/Message.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.base.bean; 2 | 3 | /** 4 | * 消息类 5 | */ 6 | public class Message { 7 | 8 | private Long to; 9 | private Long from; 10 | private String content; 11 | 12 | public Long getTo() { 13 | return to; 14 | } 15 | 16 | public void setTo(Long to) { 17 | this.to = to; 18 | } 19 | 20 | public Long getFrom() { 21 | return from; 22 | } 23 | 24 | public void setFrom(Long from) { 25 | this.from = from; 26 | } 27 | 28 | public String getContent() { 29 | return content; 30 | } 31 | 32 | public void setContent(String content) { 33 | this.content = content; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "Message{" + 39 | "to=" + to + 40 | ", from=" + from + 41 | ", content='" + content + '\'' + 42 | '}'; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/ChatOperation.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet; 2 | 3 | import com.google.common.collect.Maps; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.ApplicationContext; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.stereotype.Component; 8 | import wiki.tony.chat.comet.operation.Operation; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * 聊天操作 14 | */ 15 | @Component 16 | public class ChatOperation { 17 | 18 | @Autowired 19 | private ApplicationContext applicationContext; 20 | 21 | private Map ops = Maps.newConcurrentMap(); 22 | 23 | @Bean(name = "operations") 24 | public Map operations() { 25 | Map beans = applicationContext.getBeansOfType(Operation.class); 26 | for (Operation op : beans.values()) { 27 | ops.put(op.op(), op); 28 | } 29 | return ops; 30 | } 31 | 32 | public Operation find(Integer op) { 33 | return ops.get(op); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /comet/src/main/resources/dubbo-consumer.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 14 | 15 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/operation/MessageOperation.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.operation; 2 | 3 | import io.netty.channel.Channel; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | import wiki.tony.chat.base.bean.Constants; 9 | import wiki.tony.chat.base.service.MsgService; 10 | import wiki.tony.chat.base.bean.Proto; 11 | 12 | /** 13 | * 消息操作 14 | */ 15 | @Component 16 | public class MessageOperation extends AbstractOperation { 17 | 18 | private final Logger logger = LoggerFactory.getLogger(MessageOperation.class); 19 | 20 | @Autowired 21 | private MsgService msgService; 22 | 23 | @Override 24 | public Integer op() { 25 | return Constants.OP_MESSAGE; 26 | } 27 | 28 | @Override 29 | public void action(Channel ch, Proto proto) throws Exception { 30 | checkAuth(ch); 31 | 32 | // receive a message 33 | msgService.receive(proto); 34 | 35 | // write message reply 36 | proto.setOperation(Constants.OP_MESSAGE_REPLY); 37 | proto.setBody(null); 38 | ch.writeAndFlush(proto); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /logic/src/main/java/wiki/tony/chat/logic/LogicApplication.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.logic; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.ComponentScan; 10 | import org.springframework.context.annotation.ImportResource; 11 | 12 | import javax.annotation.Resource; 13 | 14 | /** 15 | * 程序入口 16 | */ 17 | @SpringBootApplication 18 | @EnableAutoConfiguration 19 | @ComponentScan("wiki.tony.chat.logic") 20 | @ImportResource("classpath:dubbo-provider.xml") 21 | public class LogicApplication implements CommandLineRunner { 22 | 23 | private static Logger LOG = LoggerFactory.getLogger(LogicApplication.class); 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(LogicApplication.class, args); 27 | } 28 | 29 | @Override 30 | public void run(String... strings) throws Exception { 31 | try { 32 | Thread.currentThread().join(); 33 | } catch (Exception e) { 34 | LOG.error("startup error!", e); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/operation/AuthOperation.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.operation; 2 | 3 | import io.netty.channel.Channel; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.stereotype.Component; 9 | import wiki.tony.chat.base.bean.Constants; 10 | import wiki.tony.chat.base.service.AuthService; 11 | import wiki.tony.chat.base.bean.Proto; 12 | 13 | /** 14 | * 认证操作 15 | */ 16 | @Component 17 | public class AuthOperation extends AbstractOperation { 18 | 19 | private final Logger logger = LoggerFactory.getLogger(AuthOperation.class); 20 | 21 | @Value("${server.id}") 22 | private int serverId; 23 | @Autowired 24 | private AuthService authService; 25 | 26 | @Override 27 | public Integer op() { 28 | return Constants.OP_AUTH; 29 | } 30 | 31 | @Override 32 | public void action(Channel ch, Proto proto) throws Exception { 33 | // connection auth 34 | setKey(ch, authService.auth(serverId, proto)); 35 | 36 | // write reply 37 | proto.setOperation(Constants.OP_AUTH_REPLY); 38 | proto.setBody(null); 39 | ch.writeAndFlush(proto); 40 | 41 | logger.debug("auth ok"); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /logic/src/main/resources/dubbo-provider.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 24 | 25 | 26 | 29 | 32 | -------------------------------------------------------------------------------- /base/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | netty-chat 7 | wiki.tony.chat 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | netty-chat-base 13 | 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-test 23 | test 24 | 25 | 26 | com.google.protobuf 27 | protobuf-java 28 | 29 | 30 | 31 | 32 | com.fasterxml.jackson.core 33 | jackson-databind 34 | 35 | 36 | com.google.guava 37 | guava 38 | 39 | 40 | -------------------------------------------------------------------------------- /logic/src/main/java/wiki/tony/chat/logic/config/CachingConfig.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.logic.config; 2 | 3 | import org.springframework.cache.Cache; 4 | import org.springframework.cache.CacheManager; 5 | import org.springframework.cache.annotation.CachingConfigurerSupport; 6 | import org.springframework.cache.annotation.EnableCaching; 7 | import org.springframework.cache.concurrent.ConcurrentMapCache; 8 | import org.springframework.cache.interceptor.KeyGenerator; 9 | import org.springframework.cache.interceptor.SimpleKeyGenerator; 10 | import org.springframework.cache.support.SimpleCacheManager; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | /** 18 | * Created by Tony on 4/14/16. 19 | */ 20 | @Configuration 21 | @EnableCaching 22 | public class CachingConfig extends CachingConfigurerSupport { 23 | 24 | public static final String ONLINE = "online"; 25 | 26 | @Bean 27 | @Override 28 | public CacheManager cacheManager() { 29 | SimpleCacheManager cacheManager = new SimpleCacheManager(); 30 | 31 | List caches = new ArrayList(); 32 | // Ehcache/Redis 33 | caches.add(new ConcurrentMapCache(ONLINE, false)); 34 | cacheManager.setCaches(caches); 35 | 36 | return cacheManager; 37 | } 38 | 39 | @Bean 40 | @Override 41 | public KeyGenerator keyGenerator() { 42 | return new SimpleKeyGenerator(); 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/ChatApplication.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.ComponentScan; 10 | import org.springframework.context.annotation.ImportResource; 11 | 12 | import javax.annotation.Resource; 13 | 14 | /** 15 | * 程序入口 16 | */ 17 | @SpringBootApplication 18 | @EnableAutoConfiguration 19 | @ComponentScan("wiki.tony.chat.comet") 20 | @ImportResource("classpath:dubbo-consumer.xml") 21 | public class ChatApplication implements CommandLineRunner { 22 | 23 | private static Logger LOG = LoggerFactory.getLogger(ChatApplication.class); 24 | 25 | @Resource(name = "tcpChatServer") 26 | private ChatServer tcpChatServer; 27 | @Resource(name = "webSocketChatServer") 28 | private ChatServer webSocketChatServer; 29 | 30 | 31 | public static void main(String[] args) { 32 | SpringApplication.run(ChatApplication.class, args); 33 | } 34 | 35 | @Override 36 | public void run(String... strings) throws Exception { 37 | try { 38 | tcpChatServer.start(); 39 | webSocketChatServer.start(); 40 | 41 | Thread.currentThread().join(); 42 | } catch (Exception e) { 43 | LOG.error("startup error!", e); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # netty-chat 2 | 3 | ### Protocol: 4 | 5 | | PacketLen | Header | Actual Content | 6 | | :----: |:-------:| :-------------:| 7 | | 4byte | 12byte | data | 8 | 9 | ### Packet: 10 | - PacketLen 11 | - HeaderLen 12 | - Version 13 | - Operation 14 | - SeqId 15 | - Body 16 | 17 | ### Architecture: 18 | 19 | 20 | 21 | 22 | ### Operation 23 | 24 | AuthOperation -> decode -> AuthService 25 | MessageOperation -> decode -> MessageService 26 | 27 | ### MessageQueue 28 | 29 | MQMessage 30 | MQProducer 31 | MQConsumer 32 | MQMessageListener 33 | 34 | ### Run 35 | 36 | mvn install 37 | logic: mvn spring-boot:run 38 | comet: mvn spring-boot:run 39 | 40 | ### Test 41 | 42 | Tcp: comet -> test -> ChatClient 43 | WebSocket: comet -> test -> websocket -> demo.html 44 | 45 | ### License 46 | 47 | Licensed under the Apache License, Version 2.0 (the "License"); 48 | you may not use this file except in compliance with the License. 49 | You may obtain a copy of the License at 50 | 51 | http://www.apache.org/licenses/LICENSE-2.0 52 | 53 | Unless required by applicable law or agreed to in writing, software 54 | distributed under the License is distributed on an "AS IS" BASIS, 55 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 56 | See the License for the specific language governing permissions and 57 | limitations under the License. -------------------------------------------------------------------------------- /logic/src/main/java/wiki/tony/chat/logic/service/MsgServiceImpl.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.logic.service; 2 | 3 | import com.google.protobuf.InvalidProtocolBufferException; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.stereotype.Service; 7 | import wiki.tony.chat.base.bean.Proto; 8 | import wiki.tony.chat.base.pb.Message; 9 | import wiki.tony.chat.base.service.MsgService; 10 | 11 | /** 12 | * 消息服务 13 | *

14 | * Created by Tony on 4/14/16. 15 | */ 16 | @Service("msgService") 17 | public class MsgServiceImpl implements MsgService { 18 | 19 | private Logger logger = LoggerFactory.getLogger(MsgServiceImpl.class); 20 | 21 | @Override 22 | public boolean receive(Proto proto) { 23 | logger.debug("producer:{} ", proto); 24 | switch (proto.getOperation()) { 25 | case 1: 26 | logger.info("认证消息"); 27 | break; 28 | case 2: 29 | logger.info("认证回复"); 30 | break; 31 | case 3: 32 | logger.info("心跳消息"); 33 | break; 34 | case 4: 35 | logger.info("心跳回复"); 36 | break; 37 | case 5: 38 | logger.info("发送消息"); 39 | break; 40 | case 6: 41 | logger.info("回复消息"); 42 | break; 43 | } 44 | // Message.MsgData data; 45 | // try { 46 | // data = Message.MsgData.parseFrom(proto.getBody()); 47 | // } catch (InvalidProtocolBufferException e) { 48 | // logger.error("invalid proto {} {}", proto, e.getMessage()); 49 | // } 50 | // TODO 51 | return true; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/initializer/WebSocketServerInitializer.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.initializer; 2 | 3 | import io.netty.channel.ChannelInitializer; 4 | import io.netty.channel.ChannelPipeline; 5 | import io.netty.channel.socket.nio.NioSocketChannel; 6 | import io.netty.handler.codec.http.HttpObjectAggregator; 7 | import io.netty.handler.codec.http.HttpServerCodec; 8 | import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler; 9 | import io.netty.handler.stream.ChunkedWriteHandler; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Component; 12 | import wiki.tony.chat.comet.codec.WebSocketProtoCodec; 13 | import wiki.tony.chat.comet.handler.ChatServerHandler; 14 | 15 | /** 16 | * WebSocket服务初始化类 17 | */ 18 | @Component 19 | public class WebSocketServerInitializer extends ChannelInitializer { 20 | 21 | @Autowired 22 | private WebSocketProtoCodec protoCodec; 23 | @Autowired 24 | private ChatServerHandler serverHandler; 25 | 26 | protected void initChannel(NioSocketChannel ch) throws Exception { 27 | ChannelPipeline pipeline = ch.pipeline(); 28 | // 编解码 http 请求 29 | pipeline.addLast(new HttpServerCodec()); 30 | // 写文件内容 31 | pipeline.addLast(new ChunkedWriteHandler()); 32 | // 聚合解码 HttpRequest/HttpContent/LastHttpContent 到 FullHttpRequest 33 | // 保证接收的 Http 请求的完整性 34 | pipeline.addLast(new HttpObjectAggregator(64 * 1024)); 35 | // 处理其他的 WebSocketFrame 36 | pipeline.addLast(new WebSocketServerProtocolHandler("/chat")); 37 | // 处理 TextWebSocketFrame 38 | pipeline.addLast(protoCodec); 39 | pipeline.addLast(serverHandler); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /logic/src/main/java/wiki/tony/chat/logic/service/AuthServiceImpl.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.logic.service; 2 | 3 | import com.google.protobuf.InvalidProtocolBufferException; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.cache.CacheManager; 8 | import org.springframework.stereotype.Component; 9 | import org.springframework.stereotype.Service; 10 | import wiki.tony.chat.base.bean.Proto; 11 | import wiki.tony.chat.base.exception.ConnectionAuthException; 12 | import wiki.tony.chat.base.pb.Auth; 13 | import wiki.tony.chat.base.service.AuthService; 14 | import wiki.tony.chat.logic.config.CachingConfig; 15 | 16 | /** 17 | * 受权 18 | *

19 | * Created by Tony on 4/14/16. 20 | */ 21 | @Service("authService") 22 | public class AuthServiceImpl implements AuthService { 23 | 24 | private Logger logger = LoggerFactory.getLogger(AuthServiceImpl.class); 25 | 26 | @Autowired 27 | private CacheManager cacheManager; 28 | 29 | @Override 30 | public String auth(int serverId, Proto proto) throws ConnectionAuthException { 31 | Auth.AuthReq req; 32 | try { 33 | req = Auth.AuthReq.parseFrom(proto.getBody()); 34 | } catch (InvalidProtocolBufferException e) { 35 | logger.error("invalid proto {} {}", proto, e.getMessage()); 36 | throw new ConnectionAuthException("invalid proto", e); 37 | } 38 | cacheManager.getCache(CachingConfig.ONLINE).put(req.getUid(), serverId); 39 | 40 | logger.debug("auth serverId={}, userId={}, token={}", serverId, req.getUid(), req.getToken()); 41 | return encodeKey(req.getUid()); 42 | } 43 | 44 | @Override 45 | public boolean quit(int serverId, String key) { 46 | logger.debug("client quit uid={}, key={}", serverId, key); 47 | return true; 48 | } 49 | 50 | 51 | private String encodeKey(int uid) { 52 | return uid + ""; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /base/src/main/java/wiki/tony/chat/base/bean/Proto.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.base.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 协议类 7 | */ 8 | public class Proto implements Serializable { 9 | 10 | public static final short HEADER_LENGTH = 16; 11 | public static final short VERSION = 1; 12 | private int packetLen; 13 | private short headerLen; 14 | private short version; 15 | private int operation; 16 | private int seqId; 17 | private byte[] body; 18 | 19 | public int getPacketLen() { 20 | return packetLen; 21 | } 22 | 23 | public void setPacketLen(int packetLen) { 24 | this.packetLen = packetLen; 25 | } 26 | 27 | public short getHeaderLen() { 28 | return headerLen; 29 | } 30 | 31 | public void setHeaderLen(short headerLen) { 32 | this.headerLen = headerLen; 33 | } 34 | 35 | public short getVersion() { 36 | return version; 37 | } 38 | 39 | public void setVersion(short version) { 40 | this.version = version; 41 | } 42 | 43 | public int getOperation() { 44 | return operation; 45 | } 46 | 47 | public void setOperation(int operation) { 48 | this.operation = operation; 49 | } 50 | 51 | public int getSeqId() { 52 | return seqId; 53 | } 54 | 55 | public void setSeqId(int seqId) { 56 | this.seqId = seqId; 57 | } 58 | 59 | public byte[] getBody() { 60 | return body; 61 | } 62 | 63 | public void setBody(byte[] body) { 64 | this.body = body; 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | String text; 70 | if (body == null) { 71 | text = "null"; 72 | } else { 73 | text = new String(body); 74 | } 75 | return "Proto{" + 76 | "packetLen=" + packetLen + 77 | ", headerLen=" + headerLen + 78 | ", version=" + version + 79 | ", operation=" + operation + 80 | ", seqId=" + seqId + 81 | ", body=" + text + 82 | '}'; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/server/TcpChatServer.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.server; 2 | 3 | import io.netty.bootstrap.ServerBootstrap; 4 | import io.netty.channel.ChannelFuture; 5 | import io.netty.channel.EventLoopGroup; 6 | import io.netty.channel.nio.NioEventLoopGroup; 7 | import io.netty.channel.socket.nio.NioServerSocketChannel; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.beans.factory.annotation.Value; 12 | import org.springframework.stereotype.Component; 13 | import wiki.tony.chat.comet.ChatServer; 14 | import wiki.tony.chat.comet.initializer.TcpServerInitializer; 15 | 16 | /** 17 | * tcp server 18 | *

19 | * Created by Tony on 4/13/16. 20 | */ 21 | @Component("tcpChatServer") 22 | public class TcpChatServer implements ChatServer { 23 | 24 | private Logger logger = LoggerFactory.getLogger(TcpChatServer.class); 25 | 26 | @Value("${server.tcp.port:9090}") 27 | private int port; 28 | @Autowired 29 | private TcpServerInitializer serverInitializer; 30 | 31 | private EventLoopGroup bossGroup = new NioEventLoopGroup(); 32 | private EventLoopGroup workGroup = new NioEventLoopGroup(); 33 | 34 | private ChannelFuture channelFuture; 35 | 36 | @Override 37 | public void start() throws Exception { 38 | try { 39 | ServerBootstrap b = new ServerBootstrap() 40 | .group(bossGroup, workGroup) 41 | .channel(NioServerSocketChannel.class) 42 | .childHandler(serverInitializer); 43 | 44 | logger.info("Starting TcpChatServer... Port: " + port); 45 | 46 | channelFuture = b.bind(port).sync(); 47 | 48 | } finally { 49 | Runtime.getRuntime().addShutdownHook(new Thread() { 50 | @Override 51 | public void run() { 52 | shutdown(); 53 | } 54 | }); 55 | } 56 | } 57 | 58 | @Override 59 | public void restart() throws Exception { 60 | shutdown(); 61 | start(); 62 | } 63 | 64 | @Override 65 | public void shutdown() { 66 | if (channelFuture != null) { 67 | channelFuture.channel().close().syncUninterruptibly(); 68 | } 69 | if (bossGroup != null) { 70 | bossGroup.shutdownGracefully(); 71 | } 72 | if (workGroup != null) { 73 | workGroup.shutdownGracefully(); 74 | } 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/codec/TcpProtoCodec.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.codec; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.buffer.ByteBufAllocator; 5 | import io.netty.channel.ChannelHandler; 6 | import io.netty.channel.ChannelHandlerContext; 7 | import io.netty.handler.codec.MessageToMessageCodec; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.stereotype.Component; 11 | import wiki.tony.chat.base.bean.Proto; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * TCP协议加解密 17 | */ 18 | @Component 19 | @ChannelHandler.Sharable 20 | public class TcpProtoCodec extends MessageToMessageCodec { 21 | 22 | private Logger logger = LoggerFactory.getLogger(TcpProtoCodec.class); 23 | 24 | @Override 25 | protected void encode(ChannelHandlerContext channelHandlerContext, Proto proto, List list) throws Exception { 26 | ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(); 27 | if (proto.getBody() != null) { 28 | byteBuf.writeInt(Proto.HEADER_LENGTH + proto.getBody().length); 29 | byteBuf.writeShort(Proto.HEADER_LENGTH); 30 | byteBuf.writeShort(Proto.VERSION); 31 | byteBuf.writeInt(proto.getOperation()); 32 | byteBuf.writeInt(proto.getSeqId()); 33 | byteBuf.writeBytes(proto.getBody()); 34 | } else { 35 | byteBuf.writeInt(Proto.HEADER_LENGTH); 36 | byteBuf.writeShort(Proto.HEADER_LENGTH); 37 | byteBuf.writeShort(Proto.VERSION); 38 | byteBuf.writeInt(proto.getOperation()); 39 | byteBuf.writeInt(proto.getSeqId()); 40 | } 41 | 42 | list.add(byteBuf); 43 | 44 | logger.debug("encode: {}", proto); 45 | } 46 | 47 | @Override 48 | protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List list) throws Exception { 49 | Proto proto = new Proto(); 50 | proto.setPacketLen(byteBuf.readInt()); 51 | proto.setHeaderLen(byteBuf.readShort()); 52 | proto.setVersion(byteBuf.readShort()); 53 | proto.setOperation(byteBuf.readInt()); 54 | proto.setSeqId(byteBuf.readInt()); 55 | if (proto.getPacketLen() > proto.getHeaderLen()) { 56 | byte[] bytes = new byte[proto.getPacketLen() - proto.getHeaderLen()]; 57 | byteBuf.readBytes(bytes); 58 | proto.setBody(bytes); 59 | } 60 | 61 | list.add(proto); 62 | 63 | logger.debug("decode: {}", proto); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/server/WebSocketChatServer.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.server; 2 | 3 | import io.netty.bootstrap.ServerBootstrap; 4 | import io.netty.channel.ChannelFuture; 5 | import io.netty.channel.EventLoopGroup; 6 | import io.netty.channel.nio.NioEventLoopGroup; 7 | import io.netty.channel.socket.nio.NioServerSocketChannel; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.beans.factory.annotation.Value; 12 | import org.springframework.stereotype.Component; 13 | import wiki.tony.chat.comet.ChatServer; 14 | import wiki.tony.chat.comet.initializer.WebSocketServerInitializer; 15 | 16 | /** 17 | * websocket server 18 | *

19 | * Created by Tony on 4/13/16. 20 | */ 21 | @Component("webSocketChatServer") 22 | public class WebSocketChatServer implements ChatServer { 23 | 24 | private Logger logger = LoggerFactory.getLogger(WebSocketChatServer.class); 25 | 26 | @Value("${server.websocket.port:9090}") 27 | private int port; 28 | @Autowired 29 | private WebSocketServerInitializer serverInitializer; 30 | 31 | private final EventLoopGroup bossGroup = new NioEventLoopGroup(); 32 | private final EventLoopGroup workGroup = new NioEventLoopGroup(); 33 | 34 | private ChannelFuture channelFuture; 35 | 36 | @Override 37 | public void start() throws Exception { 38 | try { 39 | ServerBootstrap b = new ServerBootstrap() 40 | .group(bossGroup, workGroup) 41 | .channel(NioServerSocketChannel.class) 42 | .childHandler(serverInitializer); 43 | 44 | logger.info("Starting WebSocketChatServer... Port: " + port); 45 | 46 | channelFuture = b.bind(port).sync(); 47 | } finally { 48 | Runtime.getRuntime().addShutdownHook(new Thread() { 49 | @Override 50 | public void run() { 51 | shutdown(); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | @Override 58 | public void restart() throws Exception { 59 | shutdown(); 60 | start(); 61 | } 62 | 63 | @Override 64 | public void shutdown() { 65 | if (channelFuture != null) { 66 | channelFuture.channel().close().syncUninterruptibly(); 67 | } 68 | if (bossGroup != null) { 69 | bossGroup.shutdownGracefully(); 70 | } 71 | if (workGroup != null) { 72 | workGroup.shutdownGracefully(); 73 | } 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /logic/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | netty-chat 7 | wiki.tony.chat 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | netty-chat-logic 13 | 14 | 15 | 16 | 17 | wiki.tony.chat 18 | netty-chat-base 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-test 29 | test 30 | 31 | 32 | 33 | 34 | com.alibaba 35 | dubbo 36 | 37 | 38 | org.springframework 39 | spring 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.apache.zookeeper 47 | zookeeper 48 | 49 | 50 | log4j 51 | log4j 52 | 53 | 54 | org.slf4j 55 | slf4j-log4j12 56 | 57 | 58 | 59 | 60 | 61 | 62 | com.github.sgroschupf 63 | zkclient 64 | 65 | 66 | log4j 67 | log4j 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/codec/WebSocketProtoCodec.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.codec; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.buffer.ByteBufAllocator; 5 | import io.netty.channel.ChannelHandler; 6 | import io.netty.channel.ChannelHandlerContext; 7 | import io.netty.handler.codec.MessageToMessageCodec; 8 | import io.netty.handler.codec.http.websocketx.WebSocketFrame; 9 | import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.stereotype.Component; 13 | import wiki.tony.chat.base.bean.Proto; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * WebSocket 协议加解密 19 | */ 20 | @Component 21 | @ChannelHandler.Sharable 22 | public class WebSocketProtoCodec extends MessageToMessageCodec { 23 | 24 | private Logger logger = LoggerFactory.getLogger(TcpProtoCodec.class); 25 | 26 | @Override 27 | protected void encode(ChannelHandlerContext ctx, Proto proto, List list) throws Exception { 28 | ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(); 29 | if (proto.getBody() != null) { 30 | byteBuf.writeInt(Proto.HEADER_LENGTH + proto.getBody().length); 31 | byteBuf.writeShort(Proto.HEADER_LENGTH); 32 | byteBuf.writeShort(Proto.VERSION); 33 | byteBuf.writeInt(proto.getOperation()); 34 | byteBuf.writeInt(proto.getSeqId()); 35 | byteBuf.writeBytes(proto.getBody()); 36 | } else { 37 | byteBuf.writeInt(Proto.HEADER_LENGTH); 38 | byteBuf.writeShort(Proto.HEADER_LENGTH); 39 | byteBuf.writeShort(Proto.VERSION); 40 | byteBuf.writeInt(proto.getOperation()); 41 | byteBuf.writeInt(proto.getSeqId()); 42 | } 43 | 44 | list.add(new BinaryWebSocketFrame(byteBuf)); 45 | 46 | logger.debug("encode: {}", proto); 47 | } 48 | 49 | @Override 50 | protected void decode(ChannelHandlerContext ctx, WebSocketFrame webSocketFrame, List list) throws Exception { 51 | ByteBuf byteBuf = webSocketFrame.content(); 52 | Proto proto = new Proto(); 53 | proto.setPacketLen(byteBuf.readInt()); 54 | proto.setHeaderLen(byteBuf.readShort()); 55 | proto.setVersion(byteBuf.readShort()); 56 | proto.setOperation(byteBuf.readInt()); 57 | proto.setSeqId(byteBuf.readInt()); 58 | if (proto.getPacketLen() > proto.getHeaderLen()) { 59 | byte[] bytes = new byte[proto.getPacketLen() - proto.getHeaderLen()]; 60 | byteBuf.readBytes(bytes); 61 | proto.setBody(bytes); 62 | } 63 | 64 | list.add(proto); 65 | 66 | logger.debug("decode: {}", proto); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /comet/src/test/java/wiki/tony/chat/comet/client/ChatClient.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.client; 2 | 3 | import com.google.protobuf.ByteString; 4 | import io.netty.bootstrap.Bootstrap; 5 | import io.netty.channel.ChannelFuture; 6 | import io.netty.channel.ChannelInitializer; 7 | import io.netty.channel.EventLoopGroup; 8 | import io.netty.channel.nio.NioEventLoopGroup; 9 | import io.netty.channel.socket.SocketChannel; 10 | import io.netty.channel.socket.nio.NioSocketChannel; 11 | import wiki.tony.chat.base.bean.Proto; 12 | import wiki.tony.chat.base.pb.Auth; 13 | import wiki.tony.chat.base.pb.Message; 14 | import wiki.tony.chat.comet.codec.TcpProtoCodec; 15 | 16 | /** 17 | * Created by Tony on 4/14/16. 18 | */ 19 | public class ChatClient { 20 | private final String host; 21 | private final int port; 22 | 23 | public ChatClient(String host, int port) { 24 | this.host = host; 25 | this.port = port; 26 | } 27 | 28 | public void start() throws Exception { 29 | EventLoopGroup group = new NioEventLoopGroup(); 30 | 31 | try { 32 | Bootstrap b = new Bootstrap() 33 | .group(group) 34 | .channel(NioSocketChannel.class) 35 | .remoteAddress(host, port) 36 | .handler(new ChannelInitializer() { 37 | protected void initChannel(SocketChannel ch) throws Exception { 38 | ch.pipeline().addLast(new TcpProtoCodec()); 39 | } 40 | }); 41 | 42 | ChannelFuture f = b.connect().sync(); 43 | 44 | Auth.AuthReq authReq = Auth.AuthReq.newBuilder() 45 | .setUid(1) 46 | .setToken("test") 47 | .build(); 48 | Proto proto = new Proto(); 49 | proto.setVersion((short) 1); 50 | proto.setOperation(0); 51 | proto.setBody(authReq.toByteArray()); 52 | f.channel().writeAndFlush(proto); 53 | 54 | Message.MsgData msgData= Message.MsgData.newBuilder() 55 | .setTo(1) 56 | .setType(Message.MsgType.SINGLE_TEXT) 57 | .setData(ByteString.copyFromUtf8("TEST")) 58 | .build(); 59 | proto = new Proto(); 60 | proto.setVersion((short) 1); 61 | proto.setOperation(5); 62 | proto.setBody(msgData.toByteArray()); 63 | f.channel().writeAndFlush(proto); 64 | 65 | f.channel().closeFuture().sync(); 66 | } finally { 67 | group.shutdownGracefully().sync(); 68 | } 69 | } 70 | 71 | public static void main(String[] args) throws Exception { 72 | new ChatClient("127.0.0.1", 9090).start(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /comet/src/main/java/wiki/tony/chat/comet/handler/ChatServerHandler.java: -------------------------------------------------------------------------------- 1 | package wiki.tony.chat.comet.handler; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | import io.netty.channel.SimpleChannelInboundHandler; 5 | import io.netty.handler.timeout.IdleStateEvent; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.context.annotation.Scope; 11 | import org.springframework.stereotype.Service; 12 | import wiki.tony.chat.base.bean.Proto; 13 | import io.netty.channel.ChannelHandler.Sharable; 14 | import wiki.tony.chat.base.service.AuthService; 15 | import wiki.tony.chat.base.service.MsgService; 16 | import wiki.tony.chat.comet.ChatOperation; 17 | import wiki.tony.chat.comet.operation.Operation; 18 | 19 | /** 20 | * 消息处理类 21 | */ 22 | @Sharable 23 | @Service() 24 | @Scope("prototype") 25 | public class ChatServerHandler extends SimpleChannelInboundHandler { 26 | 27 | private static final Logger LOG = LoggerFactory.getLogger(ChatServerHandler.class); 28 | 29 | @Autowired 30 | private ChatOperation chatOperation; 31 | @Autowired 32 | private AuthService authService; 33 | @Autowired 34 | private MsgService msgService; 35 | @Value("${server.id}") 36 | private int serverId; 37 | 38 | /** 39 | * 客户端连接 40 | * 41 | * @param ctx 上下文 42 | * @throws Exception 异常 43 | */ 44 | @Override 45 | public void channelActive(ChannelHandlerContext ctx) throws Exception { 46 | // 添加 47 | LOG.info("客户端与服务端连接开启"); 48 | } 49 | 50 | /** 51 | * 客户端关闭 52 | * 53 | * @param ctx 上下文 54 | * @throws Exception 异常 55 | */ 56 | @Override 57 | public void channelInactive(ChannelHandlerContext ctx) throws Exception { 58 | // 移除 59 | ctx.close(); 60 | LOG.info("客户端与服务端连接关闭"); 61 | } 62 | 63 | /** 64 | * 读取消息 65 | * 66 | * @param ctx 通道上下文 67 | * @param proto 协议 68 | * @throws Exception 异常 69 | */ 70 | @Override 71 | protected void messageReceived(ChannelHandlerContext ctx, Proto proto) throws Exception { 72 | LOG.info("收到消息"); 73 | Operation op = chatOperation.find(proto.getOperation()); 74 | if (op != null) { 75 | LOG.debug(proto.toString()); 76 | op.action(ctx.channel(), proto); 77 | msgService.receive(proto); 78 | } else { 79 | LOG.warn("Not found operationId: " + proto.getOperation()); 80 | } 81 | } 82 | 83 | /** 84 | * 异常消息 85 | * 86 | * @param ctx 通道上下文 87 | * @param cause 线程 88 | * @throws Exception 异常 89 | */ 90 | @Override 91 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { 92 | LOG.error("异常消息", cause); 93 | ctx.close(); 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /comet/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | netty-chat 7 | wiki.tony.chat 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | netty-chat-comet 13 | 14 | 15 | 16 | 17 | wiki.tony.chat 18 | netty-chat-base 19 | 20 | 21 | wiki.tony.chat 22 | netty-chat-logic 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-test 33 | test 34 | 35 | 36 | 37 | 38 | com.alibaba 39 | dubbo 40 | 41 | 42 | org.springframework 43 | spring 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.apache.zookeeper 51 | zookeeper 52 | 53 | 54 | log4j 55 | log4j 56 | 57 | 58 | org.slf4j 59 | slf4j-log4j12 60 | 61 | 62 | 63 | 64 | 65 | 66 | com.github.sgroschupf 67 | zkclient 68 | 69 | 70 | log4j 71 | log4j 72 | 73 | 74 | 75 | 76 | 77 | 78 | io.netty 79 | netty-all 80 | 81 | 82 | com.google.protobuf 83 | protobuf-java 84 | 85 | 86 | 87 | 88 | 89 | 90 | org.springframework.boot 91 | spring-boot-maven-plugin 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /docs/websocket/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | client demo 7 | 8 | 9 | 10 | 11 | 12 |

client demo

13 | 126 | 127 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | org.springframework.boot 9 | spring-boot-starter-parent 10 | 1.3.3.RELEASE 11 | 12 | wiki.tony.chat 13 | netty-chat 14 | pom 15 | 1.0-SNAPSHOT 16 | 17 | base 18 | comet 19 | logic 20 | web 21 | 22 | 23 | true 24 | 4.2.5.RELEASE 25 | 5.0.0.Alpha2 26 | 2.5.3 27 | 3.4.8 28 | 0.1 29 | 1.7.5 30 | 1.0.13 31 | 2.7.3 32 | 5.13.2 33 | 18.0 34 | 3.0.0 35 | UTF-8 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-web 43 | 44 | 45 | 46 | wiki.tony.chat 47 | netty-chat-base 48 | ${project.version} 49 | 50 | 51 | wiki.tony.chat 52 | netty-chat-comet 53 | ${project.version} 54 | 55 | 56 | wiki.tony.chat 57 | netty-chat-logic 58 | ${project.version} 59 | 60 | 61 | wiki.tony.chat 62 | netty-chat-web 63 | ${project.version} 64 | 65 | 66 | 67 | 68 | io.netty 69 | netty-all 70 | ${netty.version} 71 | 72 | 73 | com.google.protobuf 74 | protobuf-java 75 | ${protobuf.version} 76 | 77 | 78 | 79 | 80 | com.alibaba 81 | dubbo 82 | ${dubbo.version} 83 | 84 | 85 | org.springframework 86 | spring 87 | 88 | 89 | 90 | 91 | 92 | 93 | org.apache.zookeeper 94 | zookeeper 95 | ${zookeeper.version} 96 | 97 | 98 | log4j 99 | log4j 100 | 101 | 102 | org.slf4j 103 | slf4j-log4j12 104 | 105 | 106 | 107 | 108 | 109 | 110 | com.github.sgroschupf 111 | zkclient 112 | ${zkclient.version} 113 | 114 | 115 | log4j 116 | log4j 117 | 118 | 119 | 120 | 121 | 122 | 123 | com.fasterxml.jackson.core 124 | jackson-databind 125 | ${jackson.version} 126 | 127 | 128 | com.google.guava 129 | guava 130 | ${guava.version} 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | src/main/resources.${deploy.type} 139 | 140 | 141 | src/main/resources 142 | 143 | 144 | 145 | 146 | org.apache.maven.plugins 147 | maven-compiler-plugin 148 | 2.5 149 | 150 | 1.8 151 | 1.8 152 | UTF-8 153 | 154 | 155 | 156 | org.apache.maven.plugins 157 | maven-resources-plugin 158 | 2.5 159 | 160 | UTF-8 161 | false 162 | \ 163 | 164 | ${*} 165 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /docs/websocket/js/long.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | long.js (c) 2013 Daniel Wirtz 3 | Released under the Apache License, Version 2.0 4 | see: https://github.com/dcodeIO/long.js for details 5 | */ 6 | (function(d,g){"function"===typeof define&&define.amd?define([],g):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=g():(d.dcodeIO=d.dcodeIO||{}).Long=g()})(this,function(){function d(a,b,c){this.low=a|0;this.high=b|0;this.unsigned=!!c}function g(a){return!0===(a&&a.__isLong__)}function m(a,b){var c,t;if(b){a>>>=0;if(t=0<=a&&256>a)if(c=z[a])return c;c=e(a,0>(a|0)?-1:0,!0);t&&(z[a]=c)}else{a|=0;if(t=-128<=a&&128>a)if(c=A[a])return c;c=e(a,0>a?-1:0,!1);t&& 7 | (A[a]=c)}return c}function n(a,b){if(isNaN(a)||!isFinite(a))return b?p:k;if(b){if(0>a)return p;if(a>=B)return C}else{if(a<=-D)return l;if(a+1>=D)return E}return 0>a?n(-a,b).neg():e(a%4294967296|0,a/4294967296|0,b)}function e(a,b,c){return new d(a,b,c)}function x(a,b,c){if(0===a.length)throw Error("empty string");if("NaN"===a||"Infinity"===a||"+Infinity"===a||"-Infinity"===a)return k;"number"===typeof b?(c=b,b=!1):b=!!b;c=c||10;if(2>c||36d?(d=n(v(c,d)),e=e.mul(d).add(n(g))):(e=e.mul(t),e=e.add(n(g)))}e.unsigned=b;return e}function q(a){return a instanceof d?a:"number"===typeof a?n(a):"string"===typeof a?x(a):e(a.low,a.high,a.unsigned)}Object.defineProperty(d.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});d.isLong=g;var A={},z={};d.fromInt=m;d.fromNumber=n;d.fromBits= 9 | e;var v=Math.pow;d.fromString=x;d.fromValue=q;var B=4294967296*4294967296,D=B/2,F=m(16777216),k=m(0);d.ZERO=k;var p=m(0,!0);d.UZERO=p;var r=m(1);d.ONE=r;var G=m(1,!0);d.UONE=G;var y=m(-1);d.NEG_ONE=y;var E=e(-1,2147483647,!1);d.MAX_VALUE=E;var C=e(-1,-1,!0);d.MAX_UNSIGNED_VALUE=C;var l=e(0,-2147483648,!1);d.MIN_VALUE=l;var b=d.prototype;b.toInt=function(){return this.unsigned?this.low>>>0:this.low};b.toNumber=function(){return this.unsigned?4294967296*(this.high>>>0)+(this.low>>>0):4294967296*this.high+ 10 | (this.low>>>0)};b.toString=function(a){a=a||10;if(2>a||36>>0).toString(a),b=d;if(b.isZero())return f+e;for(;6>f.length;)f="0"+f;e=""+f+e}};b.getHighBits=function(){return this.high};b.getHighBitsUnsigned= 11 | function(){return this.high>>>0};b.getLowBits=function(){return this.low};b.getLowBitsUnsigned=function(){return this.low>>>0};b.getNumBitsAbs=function(){if(this.isNegative())return this.eq(l)?64:this.neg().getNumBitsAbs();for(var a=0!=this.high?this.high:this.low,b=31;0this.high};b.isPositive=function(){return this.unsigned||0<=this.high};b.isOdd= 12 | function(){return 1===(this.low&1)};b.isEven=function(){return 0===(this.low&1)};b.equals=function(a){g(a)||(a=q(a));return this.unsigned!==a.unsigned&&1===this.high>>>31&&1===a.high>>>31?!1:this.high===a.high&&this.low===a.low};b.eq=b.equals;b.notEquals=function(a){return!this.eq(a)};b.neq=b.notEquals;b.lessThan=function(a){return 0>this.comp(a)};b.lt=b.lessThan;b.lessThanOrEqual=function(a){return 0>=this.comp(a)};b.lte=b.lessThanOrEqual;b.greaterThan=function(a){return 0>>0>this.high>>>0||a.high===this.high&&a.low>>>0>this.low>>>0?-1:1:this.sub(a).isNegative()?-1:1};b.comp=b.compare;b.negate=function(){return!this.unsigned&&this.eq(l)?l:this.not().add(r)};b.neg=b.negate;b.add=function(a){g(a)||(a=q(a));var b=this.high>>>16,c=this.high&65535, 14 | d=this.low>>>16,l=a.high>>>16,f=a.high&65535,n=a.low>>>16,k;k=0+((this.low&65535)+(a.low&65535));a=0+(k>>>16);a+=d+n;d=0+(a>>>16);d+=c+f;c=0+(d>>>16);c=c+(b+l)&65535;return e((a&65535)<<16|k&65535,c<<16|d&65535,this.unsigned)};b.subtract=function(a){g(a)||(a=q(a));return this.add(a.neg())};b.sub=b.subtract;b.multiply=function(a){if(this.isZero())return k;g(a)||(a=q(a));if(a.isZero())return k;if(this.eq(l))return a.isOdd()?l:k;if(a.eq(l))return this.isOdd()?l:k;if(this.isNegative())return a.isNegative()? 15 | this.neg().mul(a.neg()):this.neg().mul(a).neg();if(a.isNegative())return this.mul(a.neg()).neg();if(this.lt(F)&&a.lt(F))return n(this.toNumber()*a.toNumber(),this.unsigned);var b=this.high>>>16,c=this.high&65535,d=this.low>>>16,w=this.low&65535,f=a.high>>>16,m=a.high&65535,p=a.low>>>16;a=a.low&65535;var u,h,s,r;r=0+w*a;s=0+(r>>>16);s+=d*a;h=0+(s>>>16);s=(s&65535)+w*p;h+=s>>>16;s&=65535;h+=c*a;u=0+(h>>>16);h=(h&65535)+d*p;u+=h>>>16;h&=65535;h+=w*m;u+=h>>>16;h&=65535;u=u+(b*a+c*p+d*m+w*f)&65535;return e(s<< 16 | 16|r&65535,u<<16|h,this.unsigned)};b.mul=b.multiply;b.divide=function(a){g(a)||(a=q(a));if(a.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?p:k;var b,c,d;if(this.unsigned){a.unsigned||(a=a.toUnsigned());if(a.gt(this))return p;if(a.gt(this.shru(1)))return G;d=p}else{if(this.eq(l)){if(a.eq(r)||a.eq(y))return l;if(a.eq(l))return r;b=this.shr(1).div(a).shl(1);if(b.eq(k))return a.isNegative()?r:y;c=this.sub(a.mul(b));return d=b.add(c.div(a))}if(a.eq(l))return this.unsigned? 17 | p:k;if(this.isNegative())return a.isNegative()?this.neg().div(a.neg()):this.neg().div(a).neg();if(a.isNegative())return this.div(a.neg()).neg();d=k}for(c=this;c.gte(a);){b=Math.max(1,Math.floor(c.toNumber()/a.toNumber()));for(var e=Math.ceil(Math.log(b)/Math.LN2),e=48>=e?1:v(2,e-48),f=n(b),m=f.mul(a);m.isNegative()||m.gt(c);)b-=e,f=n(b,this.unsigned),m=f.mul(a);f.isZero()&&(f=r);d=d.add(f);c=c.sub(m)}return d};b.div=b.divide;b.modulo=function(a){g(a)||(a=q(a));return this.sub(this.div(a).mul(a))}; 18 | b.mod=b.modulo;b.not=function(){return e(~this.low,~this.high,this.unsigned)};b.and=function(a){g(a)||(a=q(a));return e(this.low&a.low,this.high&a.high,this.unsigned)};b.or=function(a){g(a)||(a=q(a));return e(this.low|a.low,this.high|a.high,this.unsigned)};b.xor=function(a){g(a)||(a=q(a));return e(this.low^a.low,this.high^a.high,this.unsigned)};b.shiftLeft=function(a){g(a)&&(a=a.toInt());return 0===(a&=63)?this:32>a?e(this.low<>>32-a,this.unsigned):e(0,this.low<a?e(this.low>>>a|this.high<<32-a,this.high>>a,this.unsigned):e(this.high>>a-32,0<=this.high?0:-1,this.unsigned)};b.shr=b.shiftRight;b.shiftRightUnsigned=function(a){g(a)&&(a=a.toInt());a&=63;if(0===a)return this;var b=this.high;return 32>a?e(this.low>>>a|b<<32-a,b>>>a,this.unsigned):32===a?e(b,0,this.unsigned):e(b>>>a-32,0,this.unsigned)};b.shru=b.shiftRightUnsigned;b.toSigned=function(){return this.unsigned? 20 | e(this.low,this.high,!1):this};b.toUnsigned=function(){return this.unsigned?this:e(this.low,this.high,!0)};b.toBytes=function(a){return a?this.toBytesLE():this.toBytesBE()};b.toBytesLE=function(){var a=this.high,b=this.low;return[b&255,b>>>8&255,b>>>16&255,b>>>24&255,a&255,a>>>8&255,a>>>16&255,a>>>24&255]};b.toBytesBE=function(){var a=this.high,b=this.low;return[a>>>24&255,a>>>16&255,a>>>8&255,a&255,b>>>24&255,b>>>16&255,b>>>8&255,b&255]};return d}); 21 | -------------------------------------------------------------------------------- /base/src/main/java/wiki/tony/chat/base/pb/Auth.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: auth.proto 3 | 4 | package wiki.tony.chat.base.pb; 5 | 6 | public final class Auth { 7 | private Auth() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | public interface AuthReqOrBuilder extends 12 | // @@protoc_insertion_point(interface_extends:AuthReq) 13 | com.google.protobuf.MessageLiteOrBuilder { 14 | 15 | /** 16 | * optional uint32 uid = 1; 17 | */ 18 | int getUid(); 19 | 20 | /** 21 | * optional string token = 2; 22 | */ 23 | java.lang.String getToken(); 24 | /** 25 | * optional string token = 2; 26 | */ 27 | com.google.protobuf.ByteString 28 | getTokenBytes(); 29 | } 30 | /** 31 | * Protobuf type {@code AuthReq} 32 | */ 33 | public static final class AuthReq extends 34 | com.google.protobuf.GeneratedMessageLite< 35 | AuthReq, AuthReq.Builder> implements 36 | // @@protoc_insertion_point(message_implements:AuthReq) 37 | AuthReqOrBuilder { 38 | private AuthReq() { 39 | token_ = ""; 40 | } 41 | public static final int UID_FIELD_NUMBER = 1; 42 | private int uid_; 43 | /** 44 | * optional uint32 uid = 1; 45 | */ 46 | public int getUid() { 47 | return uid_; 48 | } 49 | /** 50 | * optional uint32 uid = 1; 51 | */ 52 | private void setUid(int value) { 53 | 54 | uid_ = value; 55 | } 56 | /** 57 | * optional uint32 uid = 1; 58 | */ 59 | private void clearUid() { 60 | 61 | uid_ = 0; 62 | } 63 | 64 | public static final int TOKEN_FIELD_NUMBER = 2; 65 | private java.lang.String token_; 66 | /** 67 | * optional string token = 2; 68 | */ 69 | public java.lang.String getToken() { 70 | return token_; 71 | } 72 | /** 73 | * optional string token = 2; 74 | */ 75 | public com.google.protobuf.ByteString 76 | getTokenBytes() { 77 | return com.google.protobuf.ByteString.copyFromUtf8(token_); 78 | } 79 | /** 80 | * optional string token = 2; 81 | */ 82 | private void setToken( 83 | java.lang.String value) { 84 | if (value == null) { 85 | throw new NullPointerException(); 86 | } 87 | 88 | token_ = value; 89 | } 90 | /** 91 | * optional string token = 2; 92 | */ 93 | private void clearToken() { 94 | 95 | token_ = getDefaultInstance().getToken(); 96 | } 97 | /** 98 | * optional string token = 2; 99 | */ 100 | private void setTokenBytes( 101 | com.google.protobuf.ByteString value) { 102 | if (value == null) { 103 | throw new NullPointerException(); 104 | } 105 | checkByteStringIsUtf8(value); 106 | 107 | token_ = value.toStringUtf8(); 108 | } 109 | 110 | public void writeTo(com.google.protobuf.CodedOutputStream output) 111 | throws java.io.IOException { 112 | if (uid_ != 0) { 113 | output.writeUInt32(1, uid_); 114 | } 115 | if (!token_.isEmpty()) { 116 | output.writeString(2, getToken()); 117 | } 118 | } 119 | 120 | public int getSerializedSize() { 121 | int size = memoizedSerializedSize; 122 | if (size != -1) return size; 123 | 124 | size = 0; 125 | if (uid_ != 0) { 126 | size += com.google.protobuf.CodedOutputStream 127 | .computeUInt32Size(1, uid_); 128 | } 129 | if (!token_.isEmpty()) { 130 | size += com.google.protobuf.CodedOutputStream 131 | .computeStringSize(2, getToken()); 132 | } 133 | memoizedSerializedSize = size; 134 | return size; 135 | } 136 | 137 | public static wiki.tony.chat.base.pb.Auth.AuthReq parseFrom( 138 | com.google.protobuf.ByteString data) 139 | throws com.google.protobuf.InvalidProtocolBufferException { 140 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 141 | DEFAULT_INSTANCE, data); 142 | } 143 | public static wiki.tony.chat.base.pb.Auth.AuthReq parseFrom( 144 | com.google.protobuf.ByteString data, 145 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 146 | throws com.google.protobuf.InvalidProtocolBufferException { 147 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 148 | DEFAULT_INSTANCE, data, extensionRegistry); 149 | } 150 | public static wiki.tony.chat.base.pb.Auth.AuthReq parseFrom(byte[] data) 151 | throws com.google.protobuf.InvalidProtocolBufferException { 152 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 153 | DEFAULT_INSTANCE, data); 154 | } 155 | public static wiki.tony.chat.base.pb.Auth.AuthReq parseFrom( 156 | byte[] data, 157 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 158 | throws com.google.protobuf.InvalidProtocolBufferException { 159 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 160 | DEFAULT_INSTANCE, data, extensionRegistry); 161 | } 162 | public static wiki.tony.chat.base.pb.Auth.AuthReq parseFrom(java.io.InputStream input) 163 | throws java.io.IOException { 164 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 165 | DEFAULT_INSTANCE, input); 166 | } 167 | public static wiki.tony.chat.base.pb.Auth.AuthReq parseFrom( 168 | java.io.InputStream input, 169 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 170 | throws java.io.IOException { 171 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 172 | DEFAULT_INSTANCE, input, extensionRegistry); 173 | } 174 | public static wiki.tony.chat.base.pb.Auth.AuthReq parseDelimitedFrom(java.io.InputStream input) 175 | throws java.io.IOException { 176 | return parseDelimitedFrom(DEFAULT_INSTANCE, input); 177 | } 178 | public static wiki.tony.chat.base.pb.Auth.AuthReq parseDelimitedFrom( 179 | java.io.InputStream input, 180 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 181 | throws java.io.IOException { 182 | return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); 183 | } 184 | public static wiki.tony.chat.base.pb.Auth.AuthReq parseFrom( 185 | com.google.protobuf.CodedInputStream input) 186 | throws java.io.IOException { 187 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 188 | DEFAULT_INSTANCE, input); 189 | } 190 | public static wiki.tony.chat.base.pb.Auth.AuthReq parseFrom( 191 | com.google.protobuf.CodedInputStream input, 192 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 193 | throws java.io.IOException { 194 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 195 | DEFAULT_INSTANCE, input, extensionRegistry); 196 | } 197 | 198 | public static Builder newBuilder() { 199 | return DEFAULT_INSTANCE.toBuilder(); 200 | } 201 | public static Builder newBuilder(wiki.tony.chat.base.pb.Auth.AuthReq prototype) { 202 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 203 | } 204 | 205 | /** 206 | * Protobuf type {@code AuthReq} 207 | */ 208 | public static final class Builder extends 209 | com.google.protobuf.GeneratedMessageLite.Builder< 210 | wiki.tony.chat.base.pb.Auth.AuthReq, Builder> implements 211 | // @@protoc_insertion_point(builder_implements:AuthReq) 212 | wiki.tony.chat.base.pb.Auth.AuthReqOrBuilder { 213 | // Construct using wiki.tony.chat.base.pb.Auth.AuthReq.newBuilder() 214 | private Builder() { 215 | super(DEFAULT_INSTANCE); 216 | } 217 | 218 | 219 | /** 220 | * optional uint32 uid = 1; 221 | */ 222 | public int getUid() { 223 | return instance.getUid(); 224 | } 225 | /** 226 | * optional uint32 uid = 1; 227 | */ 228 | public Builder setUid(int value) { 229 | copyOnWrite(); 230 | instance.setUid(value); 231 | return this; 232 | } 233 | /** 234 | * optional uint32 uid = 1; 235 | */ 236 | public Builder clearUid() { 237 | copyOnWrite(); 238 | instance.clearUid(); 239 | return this; 240 | } 241 | 242 | /** 243 | * optional string token = 2; 244 | */ 245 | public java.lang.String getToken() { 246 | return instance.getToken(); 247 | } 248 | /** 249 | * optional string token = 2; 250 | */ 251 | public com.google.protobuf.ByteString 252 | getTokenBytes() { 253 | return instance.getTokenBytes(); 254 | } 255 | /** 256 | * optional string token = 2; 257 | */ 258 | public Builder setToken( 259 | java.lang.String value) { 260 | copyOnWrite(); 261 | instance.setToken(value); 262 | return this; 263 | } 264 | /** 265 | * optional string token = 2; 266 | */ 267 | public Builder clearToken() { 268 | copyOnWrite(); 269 | instance.clearToken(); 270 | return this; 271 | } 272 | /** 273 | * optional string token = 2; 274 | */ 275 | public Builder setTokenBytes( 276 | com.google.protobuf.ByteString value) { 277 | copyOnWrite(); 278 | instance.setTokenBytes(value); 279 | return this; 280 | } 281 | 282 | // @@protoc_insertion_point(builder_scope:AuthReq) 283 | } 284 | protected final Object dynamicMethod( 285 | com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, 286 | Object arg0, Object arg1) { 287 | switch (method) { 288 | case NEW_MUTABLE_INSTANCE: { 289 | return new wiki.tony.chat.base.pb.Auth.AuthReq(); 290 | } 291 | case IS_INITIALIZED: { 292 | return DEFAULT_INSTANCE; 293 | } 294 | case MAKE_IMMUTABLE: { 295 | return null; 296 | } 297 | case NEW_BUILDER: { 298 | return new Builder(); 299 | } 300 | case VISIT: { 301 | Visitor visitor = (Visitor) arg0; 302 | wiki.tony.chat.base.pb.Auth.AuthReq other = (wiki.tony.chat.base.pb.Auth.AuthReq) arg1; 303 | uid_ = visitor.visitInt(uid_ != 0, uid_, 304 | other.uid_ != 0, other.uid_); 305 | token_ = visitor.visitString(!token_.isEmpty(), token_, 306 | !other.token_.isEmpty(), other.token_); 307 | if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor 308 | .INSTANCE) { 309 | } 310 | return this; 311 | } 312 | case MERGE_FROM_STREAM: { 313 | com.google.protobuf.CodedInputStream input = 314 | (com.google.protobuf.CodedInputStream) arg0; 315 | com.google.protobuf.ExtensionRegistryLite extensionRegistry = 316 | (com.google.protobuf.ExtensionRegistryLite) arg1; 317 | try { 318 | boolean done = false; 319 | while (!done) { 320 | int tag = input.readTag(); 321 | switch (tag) { 322 | case 0: 323 | done = true; 324 | break; 325 | default: { 326 | if (!input.skipField(tag)) { 327 | done = true; 328 | } 329 | break; 330 | } 331 | case 8: { 332 | 333 | uid_ = input.readUInt32(); 334 | break; 335 | } 336 | case 18: { 337 | String s = input.readStringRequireUtf8(); 338 | 339 | token_ = s; 340 | break; 341 | } 342 | } 343 | } 344 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 345 | throw new RuntimeException(e.setUnfinishedMessage(this)); 346 | } catch (java.io.IOException e) { 347 | throw new RuntimeException( 348 | new com.google.protobuf.InvalidProtocolBufferException( 349 | e.getMessage()).setUnfinishedMessage(this)); 350 | } finally { 351 | } 352 | } 353 | case GET_DEFAULT_INSTANCE: { 354 | return DEFAULT_INSTANCE; 355 | } 356 | case GET_PARSER: { 357 | if (PARSER == null) { synchronized (wiki.tony.chat.base.pb.Auth.AuthReq.class) { 358 | if (PARSER == null) { 359 | PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); 360 | } 361 | } 362 | } 363 | return PARSER; 364 | } 365 | } 366 | throw new UnsupportedOperationException(); 367 | } 368 | 369 | 370 | // @@protoc_insertion_point(class_scope:AuthReq) 371 | private static final wiki.tony.chat.base.pb.Auth.AuthReq DEFAULT_INSTANCE; 372 | static { 373 | DEFAULT_INSTANCE = new AuthReq(); 374 | DEFAULT_INSTANCE.makeImmutable(); 375 | } 376 | 377 | public static wiki.tony.chat.base.pb.Auth.AuthReq getDefaultInstance() { 378 | return DEFAULT_INSTANCE; 379 | } 380 | 381 | private static volatile com.google.protobuf.Parser PARSER; 382 | 383 | public static com.google.protobuf.Parser parser() { 384 | return DEFAULT_INSTANCE.getParserForType(); 385 | } 386 | } 387 | 388 | public interface AuthRespOrBuilder extends 389 | // @@protoc_insertion_point(interface_extends:AuthResp) 390 | com.google.protobuf.MessageLiteOrBuilder { 391 | 392 | /** 393 | * optional uint32 uid = 1; 394 | */ 395 | int getUid(); 396 | 397 | /** 398 | * optional uint32 code = 2; 399 | */ 400 | int getCode(); 401 | 402 | /** 403 | * optional string message = 3; 404 | */ 405 | java.lang.String getMessage(); 406 | /** 407 | * optional string message = 3; 408 | */ 409 | com.google.protobuf.ByteString 410 | getMessageBytes(); 411 | } 412 | /** 413 | * Protobuf type {@code AuthResp} 414 | */ 415 | public static final class AuthResp extends 416 | com.google.protobuf.GeneratedMessageLite< 417 | AuthResp, AuthResp.Builder> implements 418 | // @@protoc_insertion_point(message_implements:AuthResp) 419 | AuthRespOrBuilder { 420 | private AuthResp() { 421 | message_ = ""; 422 | } 423 | public static final int UID_FIELD_NUMBER = 1; 424 | private int uid_; 425 | /** 426 | * optional uint32 uid = 1; 427 | */ 428 | public int getUid() { 429 | return uid_; 430 | } 431 | /** 432 | * optional uint32 uid = 1; 433 | */ 434 | private void setUid(int value) { 435 | 436 | uid_ = value; 437 | } 438 | /** 439 | * optional uint32 uid = 1; 440 | */ 441 | private void clearUid() { 442 | 443 | uid_ = 0; 444 | } 445 | 446 | public static final int CODE_FIELD_NUMBER = 2; 447 | private int code_; 448 | /** 449 | * optional uint32 code = 2; 450 | */ 451 | public int getCode() { 452 | return code_; 453 | } 454 | /** 455 | * optional uint32 code = 2; 456 | */ 457 | private void setCode(int value) { 458 | 459 | code_ = value; 460 | } 461 | /** 462 | * optional uint32 code = 2; 463 | */ 464 | private void clearCode() { 465 | 466 | code_ = 0; 467 | } 468 | 469 | public static final int MESSAGE_FIELD_NUMBER = 3; 470 | private java.lang.String message_; 471 | /** 472 | * optional string message = 3; 473 | */ 474 | public java.lang.String getMessage() { 475 | return message_; 476 | } 477 | /** 478 | * optional string message = 3; 479 | */ 480 | public com.google.protobuf.ByteString 481 | getMessageBytes() { 482 | return com.google.protobuf.ByteString.copyFromUtf8(message_); 483 | } 484 | /** 485 | * optional string message = 3; 486 | */ 487 | private void setMessage( 488 | java.lang.String value) { 489 | if (value == null) { 490 | throw new NullPointerException(); 491 | } 492 | 493 | message_ = value; 494 | } 495 | /** 496 | * optional string message = 3; 497 | */ 498 | private void clearMessage() { 499 | 500 | message_ = getDefaultInstance().getMessage(); 501 | } 502 | /** 503 | * optional string message = 3; 504 | */ 505 | private void setMessageBytes( 506 | com.google.protobuf.ByteString value) { 507 | if (value == null) { 508 | throw new NullPointerException(); 509 | } 510 | checkByteStringIsUtf8(value); 511 | 512 | message_ = value.toStringUtf8(); 513 | } 514 | 515 | public void writeTo(com.google.protobuf.CodedOutputStream output) 516 | throws java.io.IOException { 517 | if (uid_ != 0) { 518 | output.writeUInt32(1, uid_); 519 | } 520 | if (code_ != 0) { 521 | output.writeUInt32(2, code_); 522 | } 523 | if (!message_.isEmpty()) { 524 | output.writeString(3, getMessage()); 525 | } 526 | } 527 | 528 | public int getSerializedSize() { 529 | int size = memoizedSerializedSize; 530 | if (size != -1) return size; 531 | 532 | size = 0; 533 | if (uid_ != 0) { 534 | size += com.google.protobuf.CodedOutputStream 535 | .computeUInt32Size(1, uid_); 536 | } 537 | if (code_ != 0) { 538 | size += com.google.protobuf.CodedOutputStream 539 | .computeUInt32Size(2, code_); 540 | } 541 | if (!message_.isEmpty()) { 542 | size += com.google.protobuf.CodedOutputStream 543 | .computeStringSize(3, getMessage()); 544 | } 545 | memoizedSerializedSize = size; 546 | return size; 547 | } 548 | 549 | public static wiki.tony.chat.base.pb.Auth.AuthResp parseFrom( 550 | com.google.protobuf.ByteString data) 551 | throws com.google.protobuf.InvalidProtocolBufferException { 552 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 553 | DEFAULT_INSTANCE, data); 554 | } 555 | public static wiki.tony.chat.base.pb.Auth.AuthResp parseFrom( 556 | com.google.protobuf.ByteString data, 557 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 558 | throws com.google.protobuf.InvalidProtocolBufferException { 559 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 560 | DEFAULT_INSTANCE, data, extensionRegistry); 561 | } 562 | public static wiki.tony.chat.base.pb.Auth.AuthResp parseFrom(byte[] data) 563 | throws com.google.protobuf.InvalidProtocolBufferException { 564 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 565 | DEFAULT_INSTANCE, data); 566 | } 567 | public static wiki.tony.chat.base.pb.Auth.AuthResp parseFrom( 568 | byte[] data, 569 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 570 | throws com.google.protobuf.InvalidProtocolBufferException { 571 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 572 | DEFAULT_INSTANCE, data, extensionRegistry); 573 | } 574 | public static wiki.tony.chat.base.pb.Auth.AuthResp parseFrom(java.io.InputStream input) 575 | throws java.io.IOException { 576 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 577 | DEFAULT_INSTANCE, input); 578 | } 579 | public static wiki.tony.chat.base.pb.Auth.AuthResp parseFrom( 580 | java.io.InputStream input, 581 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 582 | throws java.io.IOException { 583 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 584 | DEFAULT_INSTANCE, input, extensionRegistry); 585 | } 586 | public static wiki.tony.chat.base.pb.Auth.AuthResp parseDelimitedFrom(java.io.InputStream input) 587 | throws java.io.IOException { 588 | return parseDelimitedFrom(DEFAULT_INSTANCE, input); 589 | } 590 | public static wiki.tony.chat.base.pb.Auth.AuthResp parseDelimitedFrom( 591 | java.io.InputStream input, 592 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 593 | throws java.io.IOException { 594 | return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); 595 | } 596 | public static wiki.tony.chat.base.pb.Auth.AuthResp parseFrom( 597 | com.google.protobuf.CodedInputStream input) 598 | throws java.io.IOException { 599 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 600 | DEFAULT_INSTANCE, input); 601 | } 602 | public static wiki.tony.chat.base.pb.Auth.AuthResp parseFrom( 603 | com.google.protobuf.CodedInputStream input, 604 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 605 | throws java.io.IOException { 606 | return com.google.protobuf.GeneratedMessageLite.parseFrom( 607 | DEFAULT_INSTANCE, input, extensionRegistry); 608 | } 609 | 610 | public static Builder newBuilder() { 611 | return DEFAULT_INSTANCE.toBuilder(); 612 | } 613 | public static Builder newBuilder(wiki.tony.chat.base.pb.Auth.AuthResp prototype) { 614 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 615 | } 616 | 617 | /** 618 | * Protobuf type {@code AuthResp} 619 | */ 620 | public static final class Builder extends 621 | com.google.protobuf.GeneratedMessageLite.Builder< 622 | wiki.tony.chat.base.pb.Auth.AuthResp, Builder> implements 623 | // @@protoc_insertion_point(builder_implements:AuthResp) 624 | wiki.tony.chat.base.pb.Auth.AuthRespOrBuilder { 625 | // Construct using wiki.tony.chat.base.pb.Auth.AuthResp.newBuilder() 626 | private Builder() { 627 | super(DEFAULT_INSTANCE); 628 | } 629 | 630 | 631 | /** 632 | * optional uint32 uid = 1; 633 | */ 634 | public int getUid() { 635 | return instance.getUid(); 636 | } 637 | /** 638 | * optional uint32 uid = 1; 639 | */ 640 | public Builder setUid(int value) { 641 | copyOnWrite(); 642 | instance.setUid(value); 643 | return this; 644 | } 645 | /** 646 | * optional uint32 uid = 1; 647 | */ 648 | public Builder clearUid() { 649 | copyOnWrite(); 650 | instance.clearUid(); 651 | return this; 652 | } 653 | 654 | /** 655 | * optional uint32 code = 2; 656 | */ 657 | public int getCode() { 658 | return instance.getCode(); 659 | } 660 | /** 661 | * optional uint32 code = 2; 662 | */ 663 | public Builder setCode(int value) { 664 | copyOnWrite(); 665 | instance.setCode(value); 666 | return this; 667 | } 668 | /** 669 | * optional uint32 code = 2; 670 | */ 671 | public Builder clearCode() { 672 | copyOnWrite(); 673 | instance.clearCode(); 674 | return this; 675 | } 676 | 677 | /** 678 | * optional string message = 3; 679 | */ 680 | public java.lang.String getMessage() { 681 | return instance.getMessage(); 682 | } 683 | /** 684 | * optional string message = 3; 685 | */ 686 | public com.google.protobuf.ByteString 687 | getMessageBytes() { 688 | return instance.getMessageBytes(); 689 | } 690 | /** 691 | * optional string message = 3; 692 | */ 693 | public Builder setMessage( 694 | java.lang.String value) { 695 | copyOnWrite(); 696 | instance.setMessage(value); 697 | return this; 698 | } 699 | /** 700 | * optional string message = 3; 701 | */ 702 | public Builder clearMessage() { 703 | copyOnWrite(); 704 | instance.clearMessage(); 705 | return this; 706 | } 707 | /** 708 | * optional string message = 3; 709 | */ 710 | public Builder setMessageBytes( 711 | com.google.protobuf.ByteString value) { 712 | copyOnWrite(); 713 | instance.setMessageBytes(value); 714 | return this; 715 | } 716 | 717 | // @@protoc_insertion_point(builder_scope:AuthResp) 718 | } 719 | protected final Object dynamicMethod( 720 | com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, 721 | Object arg0, Object arg1) { 722 | switch (method) { 723 | case NEW_MUTABLE_INSTANCE: { 724 | return new wiki.tony.chat.base.pb.Auth.AuthResp(); 725 | } 726 | case IS_INITIALIZED: { 727 | return DEFAULT_INSTANCE; 728 | } 729 | case MAKE_IMMUTABLE: { 730 | return null; 731 | } 732 | case NEW_BUILDER: { 733 | return new Builder(); 734 | } 735 | case VISIT: { 736 | Visitor visitor = (Visitor) arg0; 737 | wiki.tony.chat.base.pb.Auth.AuthResp other = (wiki.tony.chat.base.pb.Auth.AuthResp) arg1; 738 | uid_ = visitor.visitInt(uid_ != 0, uid_, 739 | other.uid_ != 0, other.uid_); 740 | code_ = visitor.visitInt(code_ != 0, code_, 741 | other.code_ != 0, other.code_); 742 | message_ = visitor.visitString(!message_.isEmpty(), message_, 743 | !other.message_.isEmpty(), other.message_); 744 | if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor 745 | .INSTANCE) { 746 | } 747 | return this; 748 | } 749 | case MERGE_FROM_STREAM: { 750 | com.google.protobuf.CodedInputStream input = 751 | (com.google.protobuf.CodedInputStream) arg0; 752 | com.google.protobuf.ExtensionRegistryLite extensionRegistry = 753 | (com.google.protobuf.ExtensionRegistryLite) arg1; 754 | try { 755 | boolean done = false; 756 | while (!done) { 757 | int tag = input.readTag(); 758 | switch (tag) { 759 | case 0: 760 | done = true; 761 | break; 762 | default: { 763 | if (!input.skipField(tag)) { 764 | done = true; 765 | } 766 | break; 767 | } 768 | case 8: { 769 | 770 | uid_ = input.readUInt32(); 771 | break; 772 | } 773 | case 16: { 774 | 775 | code_ = input.readUInt32(); 776 | break; 777 | } 778 | case 26: { 779 | String s = input.readStringRequireUtf8(); 780 | 781 | message_ = s; 782 | break; 783 | } 784 | } 785 | } 786 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 787 | throw new RuntimeException(e.setUnfinishedMessage(this)); 788 | } catch (java.io.IOException e) { 789 | throw new RuntimeException( 790 | new com.google.protobuf.InvalidProtocolBufferException( 791 | e.getMessage()).setUnfinishedMessage(this)); 792 | } finally { 793 | } 794 | } 795 | case GET_DEFAULT_INSTANCE: { 796 | return DEFAULT_INSTANCE; 797 | } 798 | case GET_PARSER: { 799 | if (PARSER == null) { synchronized (wiki.tony.chat.base.pb.Auth.AuthResp.class) { 800 | if (PARSER == null) { 801 | PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE); 802 | } 803 | } 804 | } 805 | return PARSER; 806 | } 807 | } 808 | throw new UnsupportedOperationException(); 809 | } 810 | 811 | 812 | // @@protoc_insertion_point(class_scope:AuthResp) 813 | private static final wiki.tony.chat.base.pb.Auth.AuthResp DEFAULT_INSTANCE; 814 | static { 815 | DEFAULT_INSTANCE = new AuthResp(); 816 | DEFAULT_INSTANCE.makeImmutable(); 817 | } 818 | 819 | public static wiki.tony.chat.base.pb.Auth.AuthResp getDefaultInstance() { 820 | return DEFAULT_INSTANCE; 821 | } 822 | 823 | private static volatile com.google.protobuf.Parser PARSER; 824 | 825 | public static com.google.protobuf.Parser parser() { 826 | return DEFAULT_INSTANCE.getParserForType(); 827 | } 828 | } 829 | 830 | 831 | static { 832 | } 833 | 834 | // @@protoc_insertion_point(outer_class_scope) 835 | } 836 | -------------------------------------------------------------------------------- /docs/websocket/js/bytebuffer.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | bytebuffer.js (c) 2015 Daniel Wirtz 3 | Backing buffer: ArrayBuffer, Accessor: Uint8Array 4 | Released under the Apache License, Version 2.0 5 | see: https://github.com/dcodeIO/bytebuffer.js for details 6 | */ 7 | (function(k,m){if("function"===typeof define&&define.amd)define(["long"],m);else if("function"===typeof require&&"object"===typeof module&&module&&module.exports){var r=module,s;try{s=require("long")}catch(u){}s=m(s);r.exports=s}else(k.dcodeIO=k.dcodeIO||{}).ByteBuffer=m(k.dcodeIO.Long)})(this,function(k){function m(a){var b=0;return function(){return b>1,h=-7;f=c?f-1:0;var k=c?-1:1,p=a[b+f];f+=k;c=p&(1<<-h)-1;p>>=-h;for(h+=l;0>=-h;for(h+=d;0>1,p=23===f? 9 | Math.pow(2,-24)-Math.pow(2,-77):0;l=d?0:l-1;var m=d?1:-1,n=0>b||0===b&&0>1/b?1:0;b=Math.abs(b);isNaN(b)||Infinity===b?(b=isNaN(b)?1:0,d=h):(d=Math.floor(Math.log(b)/Math.LN2),1>b*(g=Math.pow(2,-d))&&(d--,g*=2),b=1<=d+k?b+p/g:b+p*Math.pow(2,1-k),2<=b*g&&(d++,g/=2),d+k>=h?(b=0,d=h):1<=d+k?(b=(b*g-1)*Math.pow(2,f),d+=k):(b=b*Math.pow(2,k-1)*Math.pow(2,f),d=0));for(;8<=f;a[c+l]=b&255,l+=m,b/=256,f-=8);d=d<a)throw RangeError("Illegal capacity");b=!!b;c=!!c}this.buffer=0===a?v:new ArrayBuffer(a);this.view=0===a?null:new Uint8Array(this.buffer);this.offset=0;this.markedOffset=-1;this.limit=a;this.littleEndian=b;this.noAssert=c};h.VERSION="5.0.1";h.LITTLE_ENDIAN=!0;h.BIG_ENDIAN=!1;h.DEFAULT_CAPACITY=16;h.DEFAULT_ENDIAN=h.BIG_ENDIAN;h.DEFAULT_NOASSERT=!1;h.Long=k|| 11 | null;var e=h.prototype;Object.defineProperty(e,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1});var v=new ArrayBuffer(0),w=String.fromCharCode;h.accessor=function(){return Uint8Array};h.allocate=function(a,b,c){return new h(a,b,c)};h.concat=function(a,b,c,d){if("boolean"===typeof b||"string"!==typeof b)d=c,c=b,b=void 0;for(var f=0,l=0,g=a.length,e;l=e||(b.view.set(c.view.subarray(c.offset,c.limit),b.offset),b.offset+=e);b.limit=b.offset;b.offset=0;return b};h.isByteBuffer=function(a){return!0===(a&&a.__isByteBuffer__)};h.type=function(){return ArrayBuffer};h.wrap=function(a,b,c,d){"string"!==typeof b&&(d=c,c=b,b=void 0);if("string"===typeof a)switch("undefined"===typeof b&&(b="utf8"),b){case "base64":return h.fromBase64(a,c);case "hex":return h.fromHex(a,c);case "binary":return h.fromBinary(a,c);case "utf8":return h.fromUTF8(a, 13 | c);case "debug":return h.fromDebug(a,c);default:throw Error("Unsupported encoding: "+b);}if(null===a||"object"!==typeof a)throw TypeError("Illegal buffer");if(h.isByteBuffer(a))return b=e.clone.call(a),b.markedOffset=-1,b;if(a instanceof Uint8Array)b=new h(0,c,d),0>>=0;if(0>b||b+0> 15 | this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=b,f=a.length,e=f>>3,g=0,h;for(b+=this.writeVarint32(f,b);e--;)h=!!a[g++]&1|(!!a[g++]&1)<<1|(!!a[g++]&1)<<2|(!!a[g++]&1)<<3|(!!a[g++]&1)<<4|(!!a[g++]&1)<<5|(!!a[g++]&1)<<6|(!!a[g++]&1)<<7,this.writeByte(h,b++);if(g>3,e=0,g=[];for(a+=c.length;f--;)c=this.readByte(a++),g[e++]=!!(c&1),g[e++]=!!(c&2),g[e++]=!!(c&4),g[e++]=!!(c&8),g[e++]=!!(c&16),g[e++]=!!(c&32),g[e++]=!!(c&64),g[e++]=!!(c&128);if(e>f++&1);b&&(this.offset=a);return g};e.readBytes=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+ 17 | b+" (+"+a+") <= "+this.buffer.byteLength);}var d=this.slice(b,b+a);c&&(this.offset+=a);return d};e.writeBytes=e.append;e.writeInt8=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength); 18 | }b+=1;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view[b-1]=a;c&&(this.offset+=1);return this};e.writeByte=e.writeInt8;e.readInt8=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}a=this.view[a];128===(a&128)&&(a=-(255-a+1));b&&(this.offset+= 19 | 1);return a};e.readByte=e.readInt8;e.writeUint8=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=1;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b); 20 | this.view[b-1]=a;c&&(this.offset+=1);return this};e.writeUInt8=e.writeUint8;e.readUint8=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}a=this.view[a];b&&(this.offset+=1);return a};e.readUInt8=e.readUint8;e.writeInt16=function(a,b){var c="undefined"===typeof b; 21 | c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=2;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=2;this.littleEndian?(this.view[b+1]=(a&65280)>>>8,this.view[b]=a&255):(this.view[b]=(a&65280)>>> 22 | 8,this.view[b+1]=a&255);c&&(this.offset+=2);return this};e.writeShort=e.writeInt16;e.readInt16=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength);}var c=0;this.littleEndian?(c=this.view[a],c|=this.view[a+1]<<8):(c=this.view[a]<<8,c|=this.view[a+1]);32768===(c&32768)&& 23 | (c=-(65535-c+1));b&&(this.offset+=2);return c};e.readShort=e.readInt16;e.writeUint16=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=2;var d=this.buffer.byteLength; 24 | b>d&&this.resize((d*=2)>b?d:b);b-=2;this.littleEndian?(this.view[b+1]=(a&65280)>>>8,this.view[b]=a&255):(this.view[b]=(a&65280)>>>8,this.view[b+1]=a&255);c&&(this.offset+=2);return this};e.writeUInt16=e.writeUint16;e.readUint16=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength); 25 | }var c=0;this.littleEndian?(c=this.view[a],c|=this.view[a+1]<<8):(c=this.view[a]<<8,c|=this.view[a+1]);b&&(this.offset+=2);return c};e.readUInt16=e.readUint16;e.writeInt32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+ 26 | b+" (+0) <= "+this.buffer.byteLength);}b+=4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=4;this.littleEndian?(this.view[b+3]=a>>>24&255,this.view[b+2]=a>>>16&255,this.view[b+1]=a>>>8&255,this.view[b]=a&255):(this.view[b]=a>>>24&255,this.view[b+1]=a>>>16&255,this.view[b+2]=a>>>8&255,this.view[b+3]=a&255);c&&(this.offset+=4);return this};e.writeInt=e.writeInt32;e.readInt32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a% 27 | 1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}var c=0;this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0):(c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0);b&&(this.offset+=4);return c|0};e.readInt=e.readInt32;e.writeUint32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset); 28 | if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=4;this.littleEndian?(this.view[b+3]=a>>>24&255,this.view[b+2]=a>>>16&255,this.view[b+1]=a>>>8&255,this.view[b]= 29 | a&255):(this.view[b]=a>>>24&255,this.view[b+1]=a>>>16&255,this.view[b+2]=a>>>8&255,this.view[b+3]=a&255);c&&(this.offset+=4);return this};e.writeUInt32=e.writeUint32;e.readUint32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}var c=0;this.littleEndian?(c=this.view[a+ 30 | 2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0):(c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0);b&&(this.offset+=4);return c};e.readUInt32=e.readUint32;k&&(e.writeInt64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if("string"===typeof a)a=k.fromString(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if("number"!== 31 | typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a?a=k.fromNumber(a):"string"===typeof a&&(a=k.fromString(a));b+=8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=8;var d=a.low,f=a.high;this.littleEndian?(this.view[b+3]=d>>>24&255,this.view[b+2]=d>>>16&255,this.view[b+1]=d>>>8&255,this.view[b]=d&255,b+=4,this.view[b+3]= 32 | f>>>24&255,this.view[b+2]=f>>>16&255,this.view[b+1]=f>>>8&255,this.view[b]=f&255):(this.view[b]=f>>>24&255,this.view[b+1]=f>>>16&255,this.view[b+2]=f>>>8&255,this.view[b+3]=f&255,b+=4,this.view[b]=d>>>24&255,this.view[b+1]=d>>>16&255,this.view[b+2]=d>>>8&255,this.view[b+3]=d&255);c&&(this.offset+=8);return this},e.writeLong=e.writeInt64,e.readInt64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)"); 33 | a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}var c=0,d=0;this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0,a+=4,d=this.view[a+2]<<16,d|=this.view[a+1]<<8,d|=this.view[a],d+=this.view[a+3]<<24>>>0):(d=this.view[a+1]<<16,d|=this.view[a+2]<<8,d|=this.view[a+3],d+=this.view[a]<<24>>>0,a+=4,c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0); 34 | a=new k(c,d,!1);b&&(this.offset+=8);return a},e.readLong=e.readInt64,e.writeUint64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if("string"===typeof a)a=k.fromString(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+ 35 | b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a?a=k.fromNumber(a):"string"===typeof a&&(a=k.fromString(a));b+=8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=8;var d=a.low,f=a.high;this.littleEndian?(this.view[b+3]=d>>>24&255,this.view[b+2]=d>>>16&255,this.view[b+1]=d>>>8&255,this.view[b]=d&255,b+=4,this.view[b+3]=f>>>24&255,this.view[b+2]=f>>>16&255,this.view[b+1]=f>>>8&255,this.view[b]=f&255):(this.view[b]=f>>>24&255,this.view[b+1]=f>>>16&255,this.view[b+2]=f>>>8&255, 36 | this.view[b+3]=f&255,b+=4,this.view[b]=d>>>24&255,this.view[b+1]=d>>>16&255,this.view[b+2]=d>>>8&255,this.view[b+3]=d&255);c&&(this.offset+=8);return this},e.writeUInt64=e.writeUint64,e.readUint64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}var c=0,d=0;this.littleEndian? 37 | (c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0,a+=4,d=this.view[a+2]<<16,d|=this.view[a+1]<<8,d|=this.view[a],d+=this.view[a+3]<<24>>>0):(d=this.view[a+1]<<16,d|=this.view[a+2]<<8,d|=this.view[a+3],d+=this.view[a]<<24>>>0,a+=4,c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0);a=new k(c,d,!0);b&&(this.offset+=8);return a},e.readUInt64=e.readUint64);e.writeFloat32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!== 38 | typeof a)throw TypeError("Illegal value: "+a+" (not a number)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);u(this.view,a,b-4,this.littleEndian,23,4);c&&(this.offset+=4);return this};e.writeFloat=e.writeFloat32;e.readFloat32=function(a){var b="undefined"===typeof a;b&& 39 | (a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}a=s(this.view,a,this.littleEndian,23,4);b&&(this.offset+=4);return a};e.readFloat=e.readFloat32;e.writeFloat64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a)throw TypeError("Illegal value: "+a+" (not a number)"); 40 | if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);u(this.view,a,b-8,this.littleEndian,52,8);c&&(this.offset+=8);return this};e.writeDouble=e.writeFloat64;e.readFloat64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!== 41 | a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}a=s(this.view,a,this.littleEndian,52,8);b&&(this.offset+=8);return a};e.readDouble=e.readFloat64;h.MAX_VARINT32_BYTES=5;h.calculateVarint32=function(a){a>>>=0;return 128>a?1:16384>a?2:2097152>a?3:268435456>a?4:5};h.zigZagEncode32=function(a){return((a|=0)<<1^a>>31)>>>0};h.zigZagDecode32=function(a){return a>>>1^-(a& 42 | 1)|0};e.writeVarint32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=h.calculateVarint32(a),f;b+=d;f=this.buffer.byteLength;b>f&&this.resize((f*=2)>b?f:b); 43 | b-=d;for(a>>>=0;128<=a;)f=a&127|128,this.view[b++]=f,a>>>=7;this.view[b++]=a;return c?(this.offset=b,this):d};e.writeVarint32ZigZag=function(a,b){return this.writeVarint32(h.zigZagEncode32(a),b)};e.readVarint32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength); 44 | }var c=0,d=0,f;do{if(!this.noAssert&&a>this.limit)throw a=Error("Truncated"),a.truncated=!0,a;f=this.view[a++];5>c&&(d|=(f&127)<<7*c);++c}while(0!==(f&128));d|=0;return b?(this.offset=a,d):{value:d,length:c}};e.readVarint32ZigZag=function(a){a=this.readVarint32(a);"object"===typeof a?a.value=h.zigZagDecode32(a.value):a=h.zigZagDecode32(a);return a};k&&(h.MAX_VARINT64_BYTES=10,h.calculateVarint64=function(a){"number"===typeof a?a=k.fromNumber(a):"string"===typeof a&&(a=k.fromString(a));var b=a.toInt()>>> 45 | 0,c=a.shiftRightUnsigned(28).toInt()>>>0;a=a.shiftRightUnsigned(56).toInt()>>>0;return 0==a?0==c?16384>b?128>b?1:2:2097152>b?3:4:16384>c?128>c?5:6:2097152>c?7:8:128>a?9:10},h.zigZagEncode64=function(a){"number"===typeof a?a=k.fromNumber(a,!1):"string"===typeof a?a=k.fromString(a,!1):!1!==a.unsigned&&(a=a.toSigned());return a.shiftLeft(1).xor(a.shiftRight(63)).toUnsigned()},h.zigZagDecode64=function(a){"number"===typeof a?a=k.fromNumber(a,!1):"string"===typeof a?a=k.fromString(a,!1):!1!==a.unsigned&& 46 | (a=a.toSigned());return a.shiftRightUnsigned(1).xor(a.and(k.ONE).toSigned().negate()).toSigned()},e.writeVarint64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if("string"===typeof a)a=k.fromString(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+ 47 | b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a?a=k.fromNumber(a,!1):"string"===typeof a?a=k.fromString(a,!1):!1!==a.unsigned&&(a=a.toSigned());var d=h.calculateVarint64(a),f=a.toInt()>>>0,e=a.shiftRightUnsigned(28).toInt()>>>0,g=a.shiftRightUnsigned(56).toInt()>>>0;b+=d;var t=this.buffer.byteLength;b>t&&this.resize((t*=2)>b?t:b);b-=d;switch(d){case 10:this.view[b+9]=g>>>7&1;case 9:this.view[b+8]=9!==d?g|128:g&127;case 8:this.view[b+7]=8!==d?e>>>21|128:e>>>21&127;case 7:this.view[b+6]= 48 | 7!==d?e>>>14|128:e>>>14&127;case 6:this.view[b+5]=6!==d?e>>>7|128:e>>>7&127;case 5:this.view[b+4]=5!==d?e|128:e&127;case 4:this.view[b+3]=4!==d?f>>>21|128:f>>>21&127;case 3:this.view[b+2]=3!==d?f>>>14|128:f>>>14&127;case 2:this.view[b+1]=2!==d?f>>>7|128:f>>>7&127;case 1:this.view[b]=1!==d?f|128:f&127}return c?(this.offset+=d,this):d},e.writeVarint64ZigZag=function(a,b){return this.writeVarint64(h.zigZagEncode64(a),b)},e.readVarint64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!== 49 | typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,d=0,f=0,e=0,g=0,g=this.view[a++],d=g&127;if(g&128&&(g=this.view[a++],d|=(g&127)<<7,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],d|=(g&127)<<14,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],d|=(g&127)<<21,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++], 50 | f=g&127,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],f|=(g&127)<<7,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],f|=(g&127)<<14,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],f|=(g&127)<<21,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],e=g&127,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],e|=(g&127)<<7,g&128||this.noAssert&&"undefined"===typeof g))throw Error("Buffer overrun");d=k.fromBits(d|f<<28,f>>>4| 51 | e<<24,!1);return b?(this.offset=a,d):{value:d,length:a-c}},e.readVarint64ZigZag=function(a){(a=this.readVarint64(a))&&a.value instanceof k?a.value=h.zigZagDecode64(a.value):a=h.zigZagDecode64(a);return a});e.writeCString=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);var d,f=a.length;if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");for(d=0;d>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}f=n.calculateUTF16asUTF8(m(a))[1];b+=f+1;d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=f+1;n.encodeUTF16toUTF8(m(a),function(a){this.view[b++]=a}.bind(this));this.view[b++]=0;return c?(this.offset=b,this):f};e.readCString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!== 53 | typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,d,f=-1;n.decodeUTF8toUTF16(function(){if(0===f)return null;if(a>=this.limit)throw RangeError("Illegal range: Truncated data, "+a+" < "+this.limit);f=this.view[a++];return 0===f?null:f}.bind(this),d=r(),!0);return b?(this.offset=a,d()):{string:d(),length:a-c}};e.writeIString=function(a,b){var c= 54 | "undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=b,f;f=n.calculateUTF16asUTF8(m(a),this.noAssert)[1];b+=4+f;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=4+f;this.littleEndian?(this.view[b+ 55 | 3]=f>>>24&255,this.view[b+2]=f>>>16&255,this.view[b+1]=f>>>8&255,this.view[b]=f&255):(this.view[b]=f>>>24&255,this.view[b+1]=f>>>16&255,this.view[b+2]=f>>>8&255,this.view[b+3]=f&255);b+=4;n.encodeUTF16toUTF8(m(a),function(a){this.view[b++]=a}.bind(this));if(b!==d+4+f)throw RangeError("Illegal range: Truncated data, "+b+" == "+(b+4+f));return c?(this.offset=b,this):b-d};e.readIString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+ 56 | a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}var c=a,d=this.readUint32(a),d=this.readUTF8String(d,h.METRICS_BYTES,a+=4);a+=d.length;return b?(this.offset=a,d.string):{string:d.string,length:a-c}};h.METRICS_CHARS="c";h.METRICS_BYTES="b";e.writeUTF8String=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+ 57 | b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d,f=b;d=n.calculateUTF16asUTF8(m(a))[1];b+=d;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=d;n.encodeUTF16toUTF8(m(a),function(a){this.view[b++]=a}.bind(this));return c?(this.offset=b,this):b-f};e.writeString=e.writeUTF8String;h.calculateUTF8Chars=function(a){return n.calculateUTF16asUTF8(m(a))[0]};h.calculateUTF8Bytes=function(a){return n.calculateUTF16asUTF8(m(a))[1]}; 58 | h.calculateString=h.calculateUTF8Bytes;e.readUTF8String=function(a,b,c){"number"===typeof b&&(c=b,b=void 0);var d="undefined"===typeof c;d&&(c=this.offset);"undefined"===typeof b&&(b=h.METRICS_CHARS);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+ 59 | this.buffer.byteLength);}var f=0,e=c,g;if(b===h.METRICS_CHARS){g=r();n.decodeUTF8(function(){return f>>=0;if(0>c||c+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+ 60 | c+" (+"+a+") <= "+this.buffer.byteLength);}var k=c+a;n.decodeUTF8toUTF16(function(){return c>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=b,f,e;f=n.calculateUTF16asUTF8(m(a),this.noAssert)[1];e=h.calculateVarint32(f);b+=e+f;var g=this.buffer.byteLength;b>g&&this.resize((g*=2)>b?g:b);b-=e+f;b+=this.writeVarint32(f,b);n.encodeUTF16toUTF8(m(a),function(a){this.view[b++]=a}.bind(this));if(b!==d+f+e)throw RangeError("Illegal range: Truncated data, "+ 62 | b+" == "+(b+f+e));return c?(this.offset=b,this):b-d};e.readVString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,d=this.readVarint32(a),d=this.readUTF8String(d.value,h.METRICS_BYTES,a+=d.length);a+=d.length;return b?(this.offset=a,d.string):{string:d.string, 63 | length:a-c}};e.append=function(a,b,c){if("number"===typeof b||"string"!==typeof b)c=b,b=void 0;var d="undefined"===typeof c;d&&(c=this.offset);if(!this.noAssert){if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}a instanceof h||(a=h.wrap(a,b));b=a.limit-a.offset;if(0>=b)return this;c+=b;var f=this.buffer.byteLength;c>f&&this.resize((f*=2)> 64 | c?f:c);c-=b;this.view.set(a.view.subarray(a.offset,a.limit),c);a.offset+=b;d&&(this.offset+=b);return this};e.appendTo=function(a,b){a.append(this,b);return this};e.assert=function(a){this.noAssert=!a;return this};e.capacity=function(){return this.buffer.byteLength};e.clear=function(){this.offset=0;this.limit=this.buffer.byteLength;this.markedOffset=-1;return this};e.clone=function(a){var b=new h(0,this.littleEndian,this.noAssert);a?(b.buffer=new ArrayBuffer(this.buffer.byteLength),b.view=new Uint8Array(b.buffer)): 65 | (b.buffer=this.buffer,b.view=this.view);b.offset=this.offset;b.markedOffset=this.markedOffset;b.limit=this.limit;return b};e.compact=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+ 66 | b+" <= "+this.buffer.byteLength);}if(0===a&&b===this.buffer.byteLength)return this;var c=b-a;if(0===c)return this.buffer=v,this.view=null,0<=this.markedOffset&&(this.markedOffset-=a),this.limit=this.offset=0,this;var d=new ArrayBuffer(c),f=new Uint8Array(d);f.set(this.view.subarray(a,b));this.buffer=d;this.view=f;0<=this.markedOffset&&(this.markedOffset-=a);this.offset=0;this.limit=c;return this};e.copy=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!== 67 | typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return new h(0,this.littleEndian,this.noAssert);var c=b-a,d=new h(c,this.littleEndian,this.noAssert);d.offset=0;d.limit=c;0<=d.markedOffset&&(d.markedOffset-=a);this.copyTo(d,0,a,b);return d};e.copyTo=function(a, 68 | b,c,d){var f,e;if(!this.noAssert&&!h.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer");b=(e="undefined"===typeof b)?a.offset:b|0;c=(f="undefined"===typeof c)?this.offset:c|0;d="undefined"===typeof d?this.limit:d|0;if(0>b||b>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+b+" <= "+a.buffer.byteLength);if(0>c||d>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+c+" <= "+this.buffer.byteLength);var g=d-c;if(0===g)return a;a.ensureCapacity(b+g); 69 | a.view.set(this.view.subarray(c,d),b);f&&(this.offset+=g);e&&(a.offset+=g);return this};e.ensureCapacity=function(a){var b=this.buffer.byteLength;return ba?b:a):this};e.fill=function(a,b,c){var d="undefined"===typeof b;d&&(b=this.offset);"string"===typeof a&&0>>=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal end: Not an integer");c>>>=0;if(0>b||b>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+b+" <= "+c+" <= "+this.buffer.byteLength);}if(b>=c)return this;for(;b>>=0;if(0>a||a+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+0) <= "+this.buffer.byteLength);}this.markedOffset=a;return this};e.order=function(a){if(!this.noAssert&&"boolean"!==typeof a)throw TypeError("Illegal littleEndian: Not a boolean");this.littleEndian=!!a;return this};e.LE=function(a){this.littleEndian="undefined"!==typeof a?!!a:!0;return this};e.BE=function(a){this.littleEndian= 72 | "undefined"!==typeof a?!a:!1;return this};e.prepend=function(a,b,c){if("number"===typeof b||"string"!==typeof b)c=b,b=void 0;var d="undefined"===typeof c;d&&(c=this.offset);if(!this.noAssert){if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}a instanceof h||(a=h.wrap(a,b));b=a.limit-a.offset;if(0>=b)return this;var f=b-c;if(0a)throw RangeError("Illegal capacity: 0 <= "+a);}if(this.buffer.byteLength>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return this;Array.prototype.reverse.call(this.view.subarray(a,b));return this}; 76 | e.skip=function(a){if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0}var b=this.offset+a;if(!this.noAssert&&(0>b||b>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);this.offset=b;return this};e.slice=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer"); 77 | a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}var c=this.clone();c.offset=a;c.limit=b;return c};e.toBuffer=function(a){var b=this.offset,c=this.limit;if(!this.noAssert){if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: Not an integer");b>>>=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal limit: Not an integer"); 78 | c>>>=0;if(0>b||b>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+b+" <= "+c+" <= "+this.buffer.byteLength);}if(!a&&0===b&&c===this.buffer.byteLength)return this.buffer;if(b===c)return v;a=new ArrayBuffer(c-b);(new Uint8Array(a)).set((new Uint8Array(this.buffer)).subarray(b,c),0);return a};e.toArrayBuffer=e.toBuffer;e.toString=function(a,b,c){if("undefined"===typeof a)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+ 79 | ")";"number"===typeof a&&(c=b=a="utf8");switch(a){case "utf8":return this.toUTF8(b,c);case "base64":return this.toBase64(b,c);case "hex":return this.toHex(b,c);case "binary":return this.toBinary(b,c);case "debug":return this.toDebug();case "columns":return this.toColumns();default:throw Error("Unsupported encoding: "+a);}};var x=function(){for(var a={},b=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113, 80 | 114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],c=[],d=0,f=b.length;d>2&63]),f=(d&3)<<4,null!==(d=a())?(f|=d>>4&15,c(b[(f|d>>4&15)&63]),f=(d&15)<<2,null!==(d=a())?(c(b[(f|d>>6&3)&63]),c(b[d&63])):(c(b[f&63]),c(61))):(c(b[f&63]),c(61),c(61))};a.decode=function(a,b){function d(a){throw Error("Illegal character code: "+a);}for(var f,e,h;null!==(f=a());)if(e=c[f],"undefined"===typeof e&&d(f),null!==(f=a())&& 81 | (h=c[f],"undefined"===typeof h&&d(f),b(e<<2>>>0|(h&48)>>4),null!==(f=a()))){e=c[f];if("undefined"===typeof e)if(61===f)break;else d(f);b((h&15)<<4>>>0|(e&60)>>2);if(null!==(f=a())){h=c[f];if("undefined"===typeof h)if(61===f)break;else d(f);b((e&3)<<6>>>0|h)}}};a.test=function(a){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(a)};return a}();e.toBase64=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);a|=0;b|=0;if(0>a||b>this.capacity|| 82 | a>b)throw RangeError("begin, end");var c;x.encode(function(){return aa||b>this.capacity()||a>b)throw RangeError("begin, end");if(a===b)return"";for(var c=[],d=[];ad?f+("0"+d.toString(16).toUpperCase()):f+d.toString(16).toUpperCase(),a&&(e+=32d?String.fromCharCode(d):"."));++b;if(a&&0f.length;)f+=" ";g+=f+e+"\n";f=e=""}f=b===this.offset&&b===this.limit?f+(b===this.markedOffset?"!":"|"):b===this.offset?f+(b===this.markedOffset?"[":"<"):b===this.limit?f+(b===this.markedOffset?"]":">"):f+(b===this.markedOffset?"'":a||0!==b&&b!==c?" ":"")}if(a&&" "!== 85 | f){for(;51>f.length;)f+=" ";g+=f+e+"\n"}return a?g:f};h.fromDebug=function(a,b,c){var d=a.length;b=new h((d+1)/3|0,b,c);for(var f=0,e=0,g,k=!1,m=!1,n=!1,p=!1,q=!1;f":if(!c){if(p){q=!0;break}p=!0}b.limit=e;k=!1;break;case "'":if(!c){if(n){q=!0;break}n=!0}b.markedOffset=e;k=!1;break;case " ":k=!1;break;default:if(!c&&k){q=!0;break}g=parseInt(g+a.charAt(f++),16);if(!c&&(isNaN(g)||0>g||255>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+ 88 | this.buffer.byteLength);}for(var c=Array(b-a),d;ad?c.push("0",d.toString(16)):c.push(d.toString(16));return c.join("")};h.fromHex=function(a,b,c){if(!c){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");if(0!==a.length%2)throw TypeError("Illegal str: Length not a multiple of 2");}var d=a.length;b=new h(d/2|0,b);for(var f,e=0,g=0;ef||255d?c(d&127):(2048>d?c(d>>6&31|192):(65536>d?c(d>>12&15|224):(c(d>>18&7|240),c(d>>12&63|128)),c(d>>6&63|128)),c(d&63|128)),d=null},decodeUTF8:function(a,c){for(var d,f,e,g,h=function(a){a=a.slice(0,a.indexOf(null));var b=Error(a.toString());b.name="TruncatedError";b.bytes=a;throw b;};null!==(d=a());)if(0=== 90 | (d&128))c(d);else if(192===(d&224))null===(f=a())&&h([d,f]),c((d&31)<<6|f&63);else if(224===(d&240))null!==(f=a())&&null!==(e=a())||h([d,f,e]),c((d&15)<<12|(f&63)<<6|e&63);else if(240===(d&248))null!==(f=a())&&null!==(e=a())&&null!==(g=a())||h([d,f,e,g]),c((d&7)<<18|(f&63)<<12|(e&63)<<6|g&63);else throw RangeError("Illegal starting byte: "+d);},UTF16toUTF8:function(a,c){for(var d,e=null;null!==(d=null!==e?e:a());)55296<=d&&57343>=d&&null!==(e=a())&&56320<=e&&57343>=e?(c(1024*(d-55296)+e-56320+65536), 91 | e=null):c(d);null!==e&&c(e)},UTF8toUTF16:function(a,c){var d=null;"number"===typeof a&&(d=a,a=function(){return null});for(;null!==d||null!==(d=a());)65535>=d?c(d):(d-=65536,c((d>>10)+55296),c(d%1024+56320)),d=null},encodeUTF16toUTF8:function(b,c){a.UTF16toUTF8(b,function(b){a.encodeUTF8(b,c)})},decodeUTF8toUTF16:function(b,c){a.decodeUTF8(b,function(b){a.UTF8toUTF16(b,c)})},calculateCodePoint:function(a){return 128>a?1:2048>a?2:65536>a?3:4},calculateUTF8:function(a){for(var c,d=0;null!==(c=a());)d+= 92 | 128>c?1:2048>c?2:65536>c?3:4;return d},calculateUTF16asUTF8:function(b){var c=0,d=0;a.UTF16toUTF8(b,function(a){++c;d+=128>a?1:2048>a?2:65536>a?3:4});return[c,d]}};return a}();e.toUTF8=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+ 93 | a+" <= "+b+" <= "+this.buffer.byteLength);}var c;try{n.decodeUTF8toUTF16(function(){return a 3 | Released under the Apache License, Version 2.0 4 | see: https://github.com/dcodeIO/protobuf.js for details 5 | */ 6 | (function(h,u){"function"===typeof define&&define.amd?define(["bytebuffer"],u):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=u(require("bytebuffer"),!0):(h.dcodeIO=h.dcodeIO||{}).ProtoBuf=u(h.dcodeIO.ByteBuffer)})(this,function(h,u){var d={};d.ByteBuffer=h;d.Long=h.Long||null;d.VERSION="5.0.1";d.WIRE_TYPES={};d.WIRE_TYPES.VARINT=0;d.WIRE_TYPES.BITS64=1;d.WIRE_TYPES.LDELIM=2;d.WIRE_TYPES.STARTGROUP=3;d.WIRE_TYPES.ENDGROUP=4;d.WIRE_TYPES.BITS32=5;d.PACKABLE_WIRE_TYPES= 7 | [d.WIRE_TYPES.VARINT,d.WIRE_TYPES.BITS64,d.WIRE_TYPES.BITS32];d.TYPES={int32:{name:"int32",wireType:d.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:d.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:d.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:d.WIRE_TYPES.VARINT,defaultValue:d.Long?d.Long.ZERO:void 0},uint64:{name:"uint64",wireType:d.WIRE_TYPES.VARINT,defaultValue:d.Long?d.Long.UZERO:void 0},sint64:{name:"sint64",wireType:d.WIRE_TYPES.VARINT, 8 | defaultValue:d.Long?d.Long.ZERO:void 0},bool:{name:"bool",wireType:d.WIRE_TYPES.VARINT,defaultValue:!1},"double":{name:"double",wireType:d.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:d.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:d.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:d.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:d.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:d.WIRE_TYPES.BITS64, 9 | defaultValue:d.Long?d.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:d.WIRE_TYPES.BITS64,defaultValue:d.Long?d.Long.ZERO:void 0},"float":{name:"float",wireType:d.WIRE_TYPES.BITS32,defaultValue:0},"enum":{name:"enum",wireType:d.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:d.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:d.WIRE_TYPES.STARTGROUP,defaultValue:null}};d.MAP_KEY_TYPES=[d.TYPES.int32,d.TYPES.sint32,d.TYPES.sfixed32,d.TYPES.uint32,d.TYPES.fixed32, 10 | d.TYPES.int64,d.TYPES.sint64,d.TYPES.sfixed64,d.TYPES.uint64,d.TYPES.fixed64,d.TYPES.bool,d.TYPES.string,d.TYPES.bytes];d.ID_MIN=1;d.ID_MAX=536870911;d.convertFieldsToCamelCase=!1;d.populateAccessors=!0;d.populateDefaults=!0;d.Util=function(){var b={};b.IS_NODE=!("object"!==typeof process||"[object process]"!==process+""||process.browser);b.XHR=function(){for(var b=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")}, 11 | function(){return new ActiveXObject("Microsoft.XMLHTTP")}],d=null,h=0;h]/g,RULE:/^(?:required|optional|repeated|map)$/, 13 | TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)+$/,FQTYPEREF:/^(?:\.[a-zA-Z][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/, 14 | BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g};d.DotProto=function(b,d){function h(b,c){var a=-1,l=1;"-"==b.charAt(0)&&(l=-1,b=b.substring(1));if(d.NUMBER_DEC.test(b))a=parseInt(b);else if(d.NUMBER_HEX.test(b))a=parseInt(b.substring(2),16); 15 | else if(d.NUMBER_OCT.test(b))a=parseInt(b.substring(1),8);else throw Error("illegal id value: "+(0>l?"-":"")+b);a=l*a|0;if(!c&&0>a)throw Error("illegal id value: "+(0>l?"-":"")+b);return a}function q(b){var c=1;"-"==b.charAt(0)&&(c=-1,b=b.substring(1));if(d.NUMBER_DEC.test(b))return c*parseInt(b,10);if(d.NUMBER_HEX.test(b))return c*parseInt(b.substring(2),16);if(d.NUMBER_OCT.test(b))return c*parseInt(b.substring(1),8);if("inf"===b)return Infinity*c;if("nan"===b)return NaN;if(d.NUMBER_FLT.test(b))return c* 16 | parseFloat(b);throw Error("illegal number value: "+(0>c?"-":"")+b);}function n(b,c,d){"undefined"===typeof b[c]?b[c]=d:(Array.isArray(b[c])||(b[c]=[b[c]]),b[c].push(d))}var k={},a=function(b){this.source=b+"";this.index=0;this.line=1;this.stack=[];this._stringOpen=null},e=a.prototype;e._readString=function(){var b='"'===this._stringOpen?d.STRING_DQ:d.STRING_SQ;b.lastIndex=this.index-1;var c=b.exec(this.source);if(!c)throw Error("unterminated string");this.index=b.lastIndex;this.stack.push(this._stringOpen); 17 | this._stringOpen=null;return c[1]};e.next=function(){if(0=this.source.length)return null;if(null!==this._stringOpen)return this._readString();var b,c;do{for(b=!1;d.WHITESPACE.test(c=this.source.charAt(this.index));)if("\n"===c&&++this.line,++this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if(++this.index,"/"===this.source.charAt(this.index)){for(;"\n"!==this.source.charAt(++this.index);)if(this.index==this.source.length)return null; 18 | ++this.index;++this.line;b=!0}else if("*"===(c=this.source.charAt(this.index))){do{"\n"===c&&++this.line;if(++this.index===this.source.length)return null;b=c;c=this.source.charAt(this.index)}while("*"!==b||"/"!==c);++this.index;b=!0}else return"/"}while(b);if(this.index===this.source.length)return null;c=this.index;d.DELIM.lastIndex=0;if(!d.DELIM.test(this.source.charAt(c++)))for(;c");c=this.tn.next(); 30 | if(!d.NAME.test(c))throw Error("illegal message field name: "+c);e.name=c;this.tn.skip("=");e.id=h(this.tn.next());c=this.tn.peek();"["===c&&this._parseFieldOptions(e);this.tn.skip(";")}else if(a="undefined"!==typeof a?a:this.tn.next(),"group"===a){c=this._parseMessage(b,e);if(!/^[A-Z]/.test(c.name))throw Error("illegal group name: "+c.name);e.type=c.name;e.name=c.name.toLowerCase();this.tn.omit(";")}else{if(!d.TYPE.test(a)&&!d.TYPEREF.test(a))throw Error("illegal message field type: "+a);e.type= 31 | a;c=this.tn.next();if(!d.NAME.test(c))throw Error("illegal message field name: "+c);e.name=c;this.tn.skip("=");e.id=h(this.tn.next());c=this.tn.peek();"["===c&&this._parseFieldOptions(e);this.tn.skip(";")}b.fields.push(e);return e};e._parseMessageOneOf=function(b){var c=this.tn.next();if(!d.NAME.test(c))throw Error("illegal oneof name: "+c);var a=c,e=[];for(this.tn.skip("{");"}"!==(c=this.tn.next());)c=this._parseMessageField(b,"optional",c),c.oneof=a,e.push(c.id);this.tn.omit(";");b.oneofs[a]=e}; 32 | e._parseFieldOptions=function(b){this.tn.skip("[");for(var c=!0;"]"!==this.tn.peek();)c||this.tn.skip(","),this._parseOption(b,!0),c=!1;this.tn.next()};e._parseEnum=function(b){var c={name:"",values:[],options:{}},a=this.tn.next();if(!d.NAME.test(a))throw Error("illegal name: "+a);c.name=a;for(this.tn.skip("{");"}"!==(a=this.tn.next());)if("option"===a)this._parseOption(c);else{if(!d.NAME.test(a))throw Error("illegal name: "+a);this.tn.skip("=");var e={name:a,id:h(this.tn.next(),!0)},a=this.tn.peek(); 33 | "["===a&&this._parseFieldOptions({options:{}});this.tn.skip(";");c.values.push(e)}this.tn.omit(";");b.enums.push(c)};e._parseExtensionRanges=function(){var a=[],c,d;do{for(d=[];;){c=this.tn.next();switch(c){case "min":c=b.ID_MIN;break;case "max":c=b.ID_MAX;break;default:c=q(c)}d.push(c);if(2===d.length)break;if("to"!==this.tn.peek()){d.push(c);break}this.tn.next()}a.push(d)}while(this.tn.omit(","));this.tn.skip(";");return a};e._parseExtend=function(b){var a=this.tn.next();if(!d.TYPEREF.test(a))throw Error("illegal extend reference: "+ 34 | a);var e={ref:a,fields:[]};for(this.tn.skip("{");"}"!==(a=this.tn.next());)if(d.RULE.test(a))this._parseMessageField(e,a);else if(d.TYPEREF.test(a)){if(!this.proto3)throw Error("illegal field rule: "+a);this._parseMessageField(e,"optional",a)}else throw Error("illegal extend token: "+a);this.tn.omit(";");b.messages.push(e);return e};e.toString=function(){return"Parser at line "+this.tn.line};k.Parser=f;return k}(d,d.Lang);d.Reflect=function(b){function d(g,m){if(g&&"number"===typeof g.low&&"number"=== 35 | typeof g.high&&"boolean"===typeof g.unsigned&&g.low===g.low&&g.high===g.high)return new b.Long(g.low,g.high,"undefined"===typeof m?g.unsigned:m);if("string"===typeof g)return b.Long.fromString(g,m||!1,10);if("number"===typeof g)return b.Long.fromNumber(g,m||!1);throw Error("not convertible to Long");}function p(g,m){var a=m.readVarint32(),c=a&7,a=a>>>3;switch(c){case b.WIRE_TYPES.VARINT:do a=m.readUint8();while(128===(a&128));break;case b.WIRE_TYPES.BITS64:m.offset+=8;break;case b.WIRE_TYPES.LDELIM:a= 36 | m.readVarint32();m.offset+=a;break;case b.WIRE_TYPES.STARTGROUP:p(a,m);break;case b.WIRE_TYPES.ENDGROUP:if(a===g)return!1;throw Error("Illegal GROUPEND after unknown group: "+a+" ("+g+" expected)");case b.WIRE_TYPES.BITS32:m.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+g+": "+c);}return!0}var q={},n=function(g,b,a){this.builder=g;this.parent=b;this.name=a},k=n.prototype;k.fqn=function(){var g=this.name,b=this;do{b=b.parent;if(null==b)break;g=b.name+"."+g}while(1);return g}; 37 | k.toString=function(g){return(g?this.className+" ":"")+this.fqn()};k.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};q.T=n;var a=function(g,b,a,c,d){n.call(this,g,b,a);this.className="Namespace";this.children=[];this.options=c||{};this.syntax=d||"proto2"},k=a.prototype=Object.create(n.prototype);k.getChildren=function(b){b=b||null;if(null==b)return this.children.slice();for(var a=[],c=0,d=this.children.length;cb.MAP_KEY_TYPES.indexOf(g))throw Error("Invalid map key type: "+g.name);},f=e.prototype;e.defaultFieldValue=function(g){"string"===typeof g&&(g=b.TYPES[g]);if("undefined"===typeof g.defaultValue)throw Error("default value for type "+g.name+" is not supported");return g==b.TYPES.bytes?new h(0):g.defaultValue}; 42 | f.toString=function(){return(this.name||"")+(this.isMapKey?"map":"value")+" element"};f.verifyValue=function(g){function a(b,g){throw Error("Illegal value for "+c.toString(!0)+" of type "+c.type.name+": "+b+" ("+g+")");}var c=this;switch(this.type){case b.TYPES.int32:case b.TYPES.sint32:case b.TYPES.sfixed32:return("number"!==typeof g||g===g&&0!==g%1)&&a(typeof g,"not an integer"),4294967295g?g>>>0:g;case b.TYPES.int64:case b.TYPES.sint64:case b.TYPES.sfixed64:if(b.Long)try{return d(g,!1)}catch(e){a(typeof g,e.message)}else a(typeof g,"requires Long.js");case b.TYPES.uint64:case b.TYPES.fixed64:if(b.Long)try{return d(g,!0)}catch(l){a(typeof g,l.message)}else a(typeof g,"requires Long.js");case b.TYPES.bool:return"boolean"!==typeof g&&a(typeof g,"not a boolean"),g;case b.TYPES["float"]:case b.TYPES["double"]:return"number"!==typeof g&&a(typeof g,"not a number"),g;case b.TYPES.string:return"string"=== 44 | typeof g||g&&g instanceof String||a(typeof g,"not a string"),""+g;case b.TYPES.bytes:return h.isByteBuffer(g)?g:h.wrap(g,"base64");case b.TYPES["enum"]:for(var f=this.resolvedType.getChildren(b.Reflect.Enum.Value),k=0;kg)&&a(typeof g,"not in range for uint32"),g;a(g,"not a valid enum value");case b.TYPES.group:case b.TYPES.message:g&& 45 | "object"===typeof g||a(typeof g,"object expected");if(g instanceof this.resolvedType.clazz)return g;if(g instanceof b.Builder.Message){var f={},k;for(k in g)g.hasOwnProperty(k)&&(f[k]=g[k]);g=f}return new this.resolvedType.clazz(g)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+g+" (undefined type "+this.type+")");};f.calculateLength=function(g,a){if(null===a)return 0;var c;switch(this.type){case b.TYPES.int32:return 0>a?h.calculateVarint64(a):h.calculateVarint32(a);case b.TYPES.uint32:return h.calculateVarint32(a); 46 | case b.TYPES.sint32:return h.calculateVarint32(h.zigZagEncode32(a));case b.TYPES.fixed32:case b.TYPES.sfixed32:case b.TYPES["float"]:return 4;case b.TYPES.int64:case b.TYPES.uint64:return h.calculateVarint64(a);case b.TYPES.sint64:return h.calculateVarint64(h.zigZagEncode64(a));case b.TYPES.fixed64:case b.TYPES.sfixed64:return 8;case b.TYPES.bool:return 1;case b.TYPES["enum"]:return h.calculateVarint32(a);case b.TYPES["double"]:return 8;case b.TYPES.string:return c=h.calculateUTF8Bytes(a),h.calculateVarint32(c)+ 47 | c;case b.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");return h.calculateVarint32(a.remaining())+a.remaining();case b.TYPES.message:return c=this.resolvedType.calculate(a),h.calculateVarint32(c)+c;case b.TYPES.group:return c=this.resolvedType.calculate(a),c+h.calculateVarint32(g<<3|b.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");};f.encodeValue=function(g, 48 | a,c){if(null===a)return c;switch(this.type){case b.TYPES.int32:0>a?c.writeVarint64(a):c.writeVarint32(a);break;case b.TYPES.uint32:c.writeVarint32(a);break;case b.TYPES.sint32:c.writeVarint32ZigZag(a);break;case b.TYPES.fixed32:c.writeUint32(a);break;case b.TYPES.sfixed32:c.writeInt32(a);break;case b.TYPES.int64:case b.TYPES.uint64:c.writeVarint64(a);break;case b.TYPES.sint64:c.writeVarint64ZigZag(a);break;case b.TYPES.fixed64:c.writeUint64(a);break;case b.TYPES.sfixed64:c.writeInt64(a);break;case b.TYPES.bool:"string"=== 49 | typeof a?c.writeVarint32("false"===a.toLowerCase()?0:!!a):c.writeVarint32(a?1:0);break;case b.TYPES["enum"]:c.writeVarint32(a);break;case b.TYPES["float"]:c.writeFloat32(a);break;case b.TYPES["double"]:c.writeFloat64(a);break;case b.TYPES.string:c.writeVString(a);break;case b.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");g=a.offset;c.writeVarint32(a.remaining());c.append(a);a.offset=g;break;case b.TYPES.message:g=(new h).LE(); 50 | this.resolvedType.encode(a,g);c.writeVarint32(g.offset);c.append(g.flip());break;case b.TYPES.group:this.resolvedType.encode(a,c);c.writeVarint32(g<<3|b.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");}return c};f.decode=function(a,c,d){if(c!=this.type.wireType)throw Error("Unexpected wire type for element");switch(this.type){case b.TYPES.int32:return a.readVarint32()|0;case b.TYPES.uint32:return a.readVarint32()>>> 51 | 0;case b.TYPES.sint32:return a.readVarint32ZigZag()|0;case b.TYPES.fixed32:return a.readUint32()>>>0;case b.TYPES.sfixed32:return a.readInt32()|0;case b.TYPES.int64:return a.readVarint64();case b.TYPES.uint64:return a.readVarint64().toUnsigned();case b.TYPES.sint64:return a.readVarint64ZigZag();case b.TYPES.fixed64:return a.readUint64();case b.TYPES.sfixed64:return a.readInt64();case b.TYPES.bool:return!!a.readVarint32();case b.TYPES["enum"]:return a.readVarint32();case b.TYPES["float"]:return a.readFloat(); 52 | case b.TYPES["double"]:return a.readDouble();case b.TYPES.string:return a.readVString();case b.TYPES.bytes:d=a.readVarint32();if(a.remaining()b.remaining())return null;var g=b.offset,d=b.readVarint32();if(b.remaining()>>3;if(k===b.WIRE_TYPES.ENDGROUP){if(s!==d)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+s+" ("+(d?d+" expected":"not a group")+")");break}if(f=this._fieldsById[s])f.repeated&&!f.options.packed?l[f.name].push(f.decode(k,a)):f.map?(k=f.decode(k,a),l[f.name].set(k[0],k[1])):(l[f.name]=f.decode(k,a),f.oneof&&(k=l[f.oneof.name],null!==k&&k!==f.name&&(l[k]=null),l[f.oneof.name]=f.name));else switch(k){case b.WIRE_TYPES.VARINT:a.readVarint32(); 69 | break;case b.WIRE_TYPES.BITS32:a.offset+=4;break;case b.WIRE_TYPES.BITS64:a.offset+=8;break;case b.WIRE_TYPES.LDELIM:f=a.readVarint32();a.offset+=f;break;case b.WIRE_TYPES.STARTGROUP:for(;p(s,a););break;default:throw Error("Illegal wire type for unknown field "+s+" in "+this.toString(!0)+"#decode: "+k);}}a=0;for(c=this._fields.length;a>>=3,1===c)l=this.keyElement.decode(f,a,c);else if(2===c)d=this.element.decode(f,a,c);else throw Error("Unexpected tag in map field key/value submessage");return[l,d]}return this.element.decode(c,a,this.id)};q.Message.Field=c;f=function(a,b,d,e,l,f,k){c.call(this,a,b,d,null,e,l,f,k)};f.prototype=Object.create(c.prototype);q.Message.ExtensionField=f;q.Message.OneOf=function(a,b,c){n.call(this,a,b,c);this.fields= 82 | []};var t=function(b,c,d,e,l){a.call(this,b,c,d,e,l);this.className="Enum";this.object=null};t.getName=function(a,b){for(var c=Object.keys(a),d=0,e;d=b[0]&&a.id<=b[1]&&(c=!0)});if(!c)throw Error("illegal extended field id in "+k.name+": "+a.id+" (not within valid ranges)");}var d=a.name;this.options.convertFieldsToCamelCase&& 94 | (d=b.Util.toCamelCase(d));var d=new h.Message.ExtensionField(this,k,a.rule,a.type,this.ptr.fqn()+"."+d,a.id,a.options),e=new h.Extension(this,this.ptr,a.name,d);d.extension=e;this.ptr.addChild(e);k.addChild(d)},this);else{if(!/\.?google\.protobuf\./.test(f.ref))throw Error("extended message "+f.ref+" is not defined");}else throw Error("not a valid definition: "+JSON.stringify(f));k=f=null}a=null;this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};k["import"]=function(a,d){var k= 95 | "/";if("string"===typeof d){b.Util.IS_NODE&&(d=require("path").resolve(d));if(!0===this.files[d])return this.reset();this.files[d]=!0}else if("object"===typeof d){var h=d.root;b.Util.IS_NODE&&(h=require("path").resolve(h));if(0<=h.indexOf("\\")||0<=d.file.indexOf("\\"))k="\\";h=h+k+d.file;if(!0===this.files[h])return this.reset();this.files[h]=!0}if(a.imports&&0