This repository has been archived by the owner on May 22, 2019. It is now read-only.
/
NettyWampConnectionConfig.java
64 lines (52 loc) · 2.12 KB
/
NettyWampConnectionConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package ws.wamp.jawampa.transport.netty;
import io.netty.handler.ssl.SslContext;
import ws.wamp.jawampa.connection.IWampClientConnectionConfig;
public class NettyWampConnectionConfig implements IWampClientConnectionConfig {
static final int DEFAULT_MAX_FRAME_PAYLOAD_LENGTH = 65535;
SslContext sslContext;
int maxFramePayloadLength;
NettyWampConnectionConfig(SslContext sslContext, int maxFramePayloadLength) {
this.sslContext = sslContext;
this.maxFramePayloadLength = maxFramePayloadLength;
}
/**
* the SslContext which will be used to create Ssl connections to the WAMP
* router. If this is set to null a default (unsecure) SSL client context will be created
* and used.
*/
public SslContext sslContext() {
return sslContext;
}
public int getMaxFramePayloadLength() {
return maxFramePayloadLength;
}
/**
* Builder class that must be used to create a {@link NettyWampConnectionConfig}
* instance.
*/
public static class Builder {
SslContext sslContext;
int maxFramePayloadLength = DEFAULT_MAX_FRAME_PAYLOAD_LENGTH;
/**
* Allows to set the SslContext which will be used to create Ssl connections to the WAMP
* router. If this is set to null a default (unsecure) SSL client context will be created
* and used.
* @param sslContext The SslContext that will be used for SSL connections.
* @return The {@link Builder} object
*/
public Builder withSslContext(SslContext sslContext) {
this.sslContext = sslContext;
return this;
}
public Builder withMaxFramePayloadLength(int maxFramePayloadLength){
if ( maxFramePayloadLength <= 0 ){
throw new IllegalArgumentException("maxFramePayloadLength parameter cannot be negative");
}
this.maxFramePayloadLength = maxFramePayloadLength;
return this;
}
public NettyWampConnectionConfig build() {
return new NettyWampConnectionConfig(sslContext, maxFramePayloadLength);
}
}
}