EZSocket

Simple class for TCP/IP Socket communications

License

License

GroupId

GroupId

me.aflak.libraries
ArtifactId

ArtifactId

ezsocket
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

aar
Description

Description

EZSocket
Simple class for TCP/IP Socket communications
Project URL

Project URL

https://github.com/omaflak/EZSocket
Source Code Management

Source Code Management

https://github.com/omaflak/EZSocket

Download ezsocket

How to add to project

<!-- https://jarcasting.com/artifacts/me.aflak.libraries/ezsocket/ -->
<dependency>
    <groupId>me.aflak.libraries</groupId>
    <artifactId>ezsocket</artifactId>
    <version>1.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/me.aflak.libraries/ezsocket/
implementation 'me.aflak.libraries:ezsocket:1.0'
// https://jarcasting.com/artifacts/me.aflak.libraries/ezsocket/
implementation ("me.aflak.libraries:ezsocket:1.0")
'me.aflak.libraries:ezsocket:aar:1.0'
<dependency org="me.aflak.libraries" name="ezsocket" rev="1.0">
  <artifact name="ezsocket" type="aar" />
</dependency>
@Grapes(
@Grab(group='me.aflak.libraries', module='ezsocket', version='1.0')
)
libraryDependencies += "me.aflak.libraries" % "ezsocket" % "1.0"
[me.aflak.libraries/ezsocket "1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar 2.6.3
com.android.support » appcompat-v7 jar 23.2.1

Project Modules

There are no modules declared in this project.

EZSocket

Simple TCP/IP Socket class for JAVA (and Android)

Dependencies

Gradle

compile 'me.aflak.libraries:ezsocket:1.0'

Maven

<dependency>
  <groupId>me.aflak.libraries</groupId>
  <artifactId>ezsocket</artifactId>
  <version>1.0</version>
  <type>pom</type>
</dependency>

Use

Initialise

From Client

EZSocket socket = new EZSocket("192.168.0.8", 1234, new EZSocket.EZSocketCallback() {
	@Override
	public void onConnect(EZSocket socket) {
		// socket connected
	}

	@Override
	public void onDisconnect(EZSocket socket, String message) {
		// socket disconnected
	}

	@Override
	public void onConnectError(final EZSocket socket, String message) {
		// error while connecting
	}
});

From Server

EZSocket socket = new EZSocket(server.accept(), new EZSocket.EZSocketDisconnectCallback() {
    @Override
    public void onDisconnect(EZSocket socket, String message) {
    	// socket disconnected
    }
});

Fire new event

socket.emit("your_event", "text", 42, "and as many objects as you want");

Listening for event

socket.on("your_event", new EZSocket.Listener() {
    @Override
    public void onCall(Object... obj) {
        String text = (String) obj[0];
        Integer n = (Integer) obj[1];
        String text = (String) obj[2];
        
        Log.d(msg+" : "+String.valueOf(n));
    }
});

Versions

Version
1.0