Skip to content

Commit

Permalink
refactor: Kotlin Converting LipiLee#2
Browse files Browse the repository at this point in the history
Kotlin Converting LipiLee#2
  • Loading branch information
Jungwoon committed Jan 22, 2019
1 parent 3f027dc commit 346e222
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.lipisoft.toyshark.socket;
package com.lipisoft.toyshark.socket

/**
* @author Borey Sao
* Date: June 2, 2014
*/
public class DataConst {
public static final int MAX_RECEIVE_BUFFER_SIZE = 65535;
object DataConst {
const val MAX_RECEIVE_BUFFER_SIZE = 65535
}
12 changes: 0 additions & 12 deletions app/src/main/java/com/lipisoft/toyshark/socket/IProtectSocket.java

This file was deleted.

12 changes: 12 additions & 0 deletions app/src/main/java/com/lipisoft/toyshark/socket/IProtectSocket.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.lipisoft.toyshark.socket

import java.net.DatagramSocket
import java.net.Socket

interface IProtectSocket {
fun protectSocket(socket: Socket)

fun protectSocket(socket: Int)

fun protectSocket(socket: DatagramSocket)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.lipisoft.toyshark.socket

interface IReceivePacket {
fun receive(packet: ByteArray)
}
33 changes: 17 additions & 16 deletions app/src/main/java/com/lipisoft/toyshark/socket/SocketData.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,36 @@
* 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.lipisoft.toyshark.socket;

import java.util.LinkedList;
import java.util.Queue;

/**
* Singleton data structure for storing packet data in queue. Data is pushed into this queue from
* Singleton data structure for storing packet data in queue. Data is pushed into this queue from
* VpnService as well as background worker that pull data from remote socket.
*
* @author Borey Sao
* Date: May 12, 2014
*/
public class SocketData {
private static final SocketData instance = new SocketData();
private Queue<byte[]> data;
private static final SocketData instance = new SocketData();
private Queue<byte[]> data;

public static SocketData getInstance(){
return instance;
}
public static SocketData getInstance() {
return instance;
}

private SocketData() {
data = new LinkedList<>();
}
private SocketData() {
data = new LinkedList<>();
}

public synchronized void addData(byte[] packet) {
data.add(packet);
}
public synchronized void addData(byte[] packet) {
data.add(packet);
}

public synchronized byte[] getData() {
return data.poll();
}
public synchronized byte[] getData() {
return data.poll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@
* limitations under the License.
*/

package com.lipisoft.toyshark.transport.tcp;
package com.lipisoft.toyshark.transport.tcp

/**
* @author Borey Sao
* Date: May 7, 2014
*/
public class PacketHeaderException extends Exception {
private static final long serialVersionUID = 1L;

public PacketHeaderException(String message) {
super(message);
class PacketHeaderException(message: String) : Exception(message) {
companion object {
private const val serialVersionUID = 1L
}
}

0 comments on commit 346e222

Please sign in to comment.