23 changed files with 168 additions and 92 deletions
-
16src/main/java/com/corundumstudio/socketio/Configuration.java
-
8src/main/java/com/corundumstudio/socketio/SocketIOPipelineFactory.java
-
2src/main/java/com/corundumstudio/socketio/SocketIOServer.java
-
13src/main/java/com/corundumstudio/socketio/parser/Decoder.java
-
20src/main/java/com/corundumstudio/socketio/parser/Encoder.java
-
49src/main/java/com/corundumstudio/socketio/parser/JacksonJsonSupport.java
-
30src/main/java/com/corundumstudio/socketio/parser/JsonSupport.java
-
5src/test/java/com/corundumstudio/socketio/PacketHandlerTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/DecoderAckPacketTest.java
-
23src/test/java/com/corundumstudio/socketio/parser/DecoderBaseTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/DecoderConnectionPacketTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/DecoderErrorPacketTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/DecoderEventPacketTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/DecoderJsonPacketTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/DecoderMessagePacketTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/EncoderAckPacketTest.java
-
22src/test/java/com/corundumstudio/socketio/parser/EncoderBaseTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/EncoderConnectionPacketTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/EncoderErrorPacketTest.java
-
12src/test/java/com/corundumstudio/socketio/parser/EncoderEventPacketTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/EncoderJsonPacketTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/EncoderMessagePacketTest.java
-
5src/test/java/com/corundumstudio/socketio/parser/PayloadTest.java
@ -0,0 +1,49 @@ |
|||
/** |
|||
* Copyright 2012 Nikita Koksharov |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package com.corundumstudio.socketio.parser; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.io.OutputStream; |
|||
|
|||
import org.codehaus.jackson.map.ObjectMapper; |
|||
import org.codehaus.jackson.map.annotate.JsonSerialize; |
|||
|
|||
public class JacksonJsonSupport implements JsonSupport { |
|||
|
|||
private final ObjectMapper objectMapper = new ObjectMapper(); |
|||
|
|||
public JacksonJsonSupport() { |
|||
objectMapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); |
|||
} |
|||
|
|||
@Override |
|||
public <T> T readValue(InputStream src, Class<T> valueType) throws IOException { |
|||
return objectMapper.readValue(src, valueType); |
|||
} |
|||
|
|||
@Override |
|||
public void writeValue(OutputStream out, Object value) throws IOException { |
|||
objectMapper.writeValue(out, value); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public String writeValueAsString(Object value) throws IOException { |
|||
return objectMapper.writeValueAsString(value); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,30 @@ |
|||
/** |
|||
* Copyright 2012 Nikita Koksharov |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package com.corundumstudio.socketio.parser; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.io.OutputStream; |
|||
|
|||
public interface JsonSupport { |
|||
|
|||
<T> T readValue(InputStream src, Class<T> valueType) throws IOException; |
|||
|
|||
void writeValue(OutputStream out, Object value) throws IOException; |
|||
|
|||
String writeValueAsString(Object value) throws IOException; |
|||
|
|||
} |
@ -0,0 +1,23 @@ |
|||
/** |
|||
* Copyright 2012 Nikita Koksharov |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package com.corundumstudio.socketio.parser; |
|||
|
|||
|
|||
public class DecoderBaseTest { |
|||
|
|||
protected final Decoder decoder = new Decoder(new JacksonJsonSupport()); |
|||
|
|||
} |
@ -0,0 +1,22 @@ |
|||
/** |
|||
* Copyright 2012 Nikita Koksharov |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package com.corundumstudio.socketio.parser; |
|||
|
|||
public class EncoderBaseTest { |
|||
|
|||
protected final Encoder encoder = new Encoder(new JacksonJsonSupport()); |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue