|  | 
| 16 | 16 | 
 | 
| 17 | 17 | package org.springframework.web.socket.sockjs.frame; | 
| 18 | 18 | 
 | 
|  | 19 | + | 
| 19 | 20 | import java.nio.charset.Charset; | 
| 20 | 21 | import java.nio.charset.StandardCharsets; | 
| 21 | 22 | import org.jspecify.annotations.Nullable; | 
| @@ -80,6 +81,30 @@ else if (content.charAt(0) == 'c') { | 
| 80 | 81 | 		} | 
| 81 | 82 | 	} | 
| 82 | 83 | 
 | 
|  | 84 | +	public static SockJsFrame openFrame() { | 
|  | 85 | +		return OPEN_FRAME; | 
|  | 86 | +	} | 
|  | 87 | + | 
|  | 88 | +	public static SockJsFrame heartbeatFrame() { | 
|  | 89 | +		return HEARTBEAT_FRAME; | 
|  | 90 | +	} | 
|  | 91 | + | 
|  | 92 | +	public static SockJsFrame messageFrame(SockJsMessageCodec codec, String... messages) { | 
|  | 93 | +		String encoded = codec.encode(messages); | 
|  | 94 | +		return new SockJsFrame(encoded); | 
|  | 95 | +	} | 
|  | 96 | + | 
|  | 97 | +	public static SockJsFrame closeFrameGoAway() { | 
|  | 98 | +		return CLOSE_GO_AWAY_FRAME; | 
|  | 99 | +	} | 
|  | 100 | + | 
|  | 101 | +	public static SockJsFrame closeFrameAnotherConnectionOpen() { | 
|  | 102 | +		return CLOSE_ANOTHER_CONNECTION_OPEN_FRAME; | 
|  | 103 | +	} | 
|  | 104 | + | 
|  | 105 | +	public static SockJsFrame closeFrame(int code, @Nullable String reason) { | 
|  | 106 | +		return new SockJsFrame("c[" + code + ",\"" + (reason != null ? reason : "") + "\"]"); | 
|  | 107 | +	} | 
| 83 | 108 | 
 | 
| 84 | 109 | 	/** | 
| 85 | 110 | 	 * Return the SockJS frame type. | 
| @@ -116,7 +141,6 @@ public byte[] getContentBytes() { | 
| 116 | 141 | 		} | 
| 117 | 142 | 	} | 
| 118 | 143 | 
 | 
| 119 |  | - | 
| 120 | 144 | 	@Override | 
| 121 | 145 | 	public boolean equals(@Nullable Object other) { | 
| 122 | 146 | 		return (this == other || (other instanceof SockJsFrame that && | 
| @@ -151,30 +175,4 @@ public String toString() { | 
| 151 | 175 | 		return "SockJsFrame content='" + sb + "'"; | 
| 152 | 176 | 	} | 
| 153 | 177 | 
 | 
| 154 |  | - | 
| 155 |  | -	public static SockJsFrame openFrame() { | 
| 156 |  | -		return OPEN_FRAME; | 
| 157 |  | -	} | 
| 158 |  | - | 
| 159 |  | -	public static SockJsFrame heartbeatFrame() { | 
| 160 |  | -		return HEARTBEAT_FRAME; | 
| 161 |  | -	} | 
| 162 |  | - | 
| 163 |  | -	public static SockJsFrame messageFrame(SockJsMessageCodec codec, String... messages) { | 
| 164 |  | -		String encoded = codec.encode(messages); | 
| 165 |  | -		return new SockJsFrame(encoded); | 
| 166 |  | -	} | 
| 167 |  | - | 
| 168 |  | -	public static SockJsFrame closeFrameGoAway() { | 
| 169 |  | -		return CLOSE_GO_AWAY_FRAME; | 
| 170 |  | -	} | 
| 171 |  | - | 
| 172 |  | -	public static SockJsFrame closeFrameAnotherConnectionOpen() { | 
| 173 |  | -		return CLOSE_ANOTHER_CONNECTION_OPEN_FRAME; | 
| 174 |  | -	} | 
| 175 |  | - | 
| 176 |  | -	public static SockJsFrame closeFrame(int code, @Nullable String reason) { | 
| 177 |  | -		return new SockJsFrame("c[" + code + ",\"" + (reason != null ? reason : "") + "\"]"); | 
| 178 |  | -	} | 
| 179 |  | - | 
| 180 | 178 | } | 
0 commit comments