Giter Site home page Giter Site logo

byond-message-client's Introduction

Build Status Coverage Status Javadocs License

BYOND Message Client

About

Small library for Java, which provide simple way to send messages and receive responses from BYOND server.

Installation

Maven Central JCenter

Library is deployed and provided with Maven Central and JCenter repositories.

pom.xml:

<dependency>
    <groupId>io.github.spair</groupId>
    <artifactId>byond-message-client</artifactId>
    <version>${last.version}</version>
</dependency>

build.gradle:

compile 'io.github.spair:byond-message-client:${last.version}'

Usage

There are three main classes to use:

  • ByondClient
  • ByondMessage (with ServerAddress class)
  • ByondResponse

Example:

ByondMessage message = new ByondMessage("bagil.game.tgstation13.org", 2337, "ping");
ByondResponse response = new ByondClient().sendMessage(message);

If you print response object you could see something like that:

ByondResponse(response=56.0, responseType=FLOAT_NUMBER)

Response data is an Object class, so manual class cast is needed.

Additional info:

  • On BYOND side message should be handled in World/Topic() method. Look BYOND Ref for more info.
  • If you want just to send message to BYOND and you don't care about response use sendCommand() method instead of sendMessage() or set expected response type in ByondMessage as ResponseType.NONE.
  • To control response type from BYOND set ResponseType.FLOAT_NUMBER or ResponseType.STRING in ByondMessage instance. If actual response type is different exception UnexpectedResponseException will be thrown.

Also there are some exceptions I'll recommend to handle due to significant reasons.

  1. HostUnavailableException It will be thrown if host you try to send message is currently offline. Restart moment, for example.
  2. UnexpectedResponseException Exception will be thrown while two reasons: World/Topic() doesn't return any response on your message; moment between when server already restarted, but World didn't initialized. Little chance, but you can got in this situation.

Read more in JavaDoc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.