Giter Club home page Giter Club logo

mukcast's Introduction

MuKCast

MuKCast is an light-weight client/server library for the Processing Development Environment (PDE).

MuKCast can be used to send messages between a client and a server. There are three predefined messages in the library.

  • TextMessage
  • NumberMessage
  • ImageMessage

In case there is a need for a customized message, it is possible to create a custom message by implementing the interface Message.java.

Example Server

MuKCastServer server;

PImage img1, img2;

void setup() {
  size(800, 450);
  frameRate(5);

  textAlign(CENTER, CENTER);

  img1 = loadImage("vstreamsphere01.jpg");
  img2 = loadImage("vstreamsphere02.jpg");

  img1.resize(800, 450);
  img2.resize(800, 450);

  server = new MuKCastServer(this);
  try {
  	server.startServer();
  } 
  catch(IOException e) {
    e.printStackTrace();
  }

  image(img1, 0, 110, width/2, 225);
  image(img2, width/2, 110, width/2, 225);

  textSize(48);
  text("Server: " + server.getServerInfo(), width/2, height/2);
}

void draw() {

  surface.setTitle("Server - FPS: " + frameRate);

  try {
    if (frameCount % 2 == 0) {
      server.broadcastMessage(new ImageMessage(img1));
    } else {
      server.broadcastMessage(new ImageMessage(img2));
    }
  } 
  catch(IOException e) {
    e.printStackTrace();
  }
}

Example Client

MuKCastClient client;

PImage image;

void setup() {
  size(800, 450);

  textAlign(CENTER, CENTER);

  client = new MuKCastClient(this, "localhost", 4242);
  image = createImage(800, 450, RGB);
  
  try {
    client.connect();
  } 
  catch(IOException e) {
    e.printStackTrace();
  }
}

void draw() {
  background(0);

  surface.setTitle("Client - FPS: " + frameRate);

  if (image != null) {
    image(image, 0, 0, width, height);
  }

  textSize(48);
  text("Client: " + client.getClientInfo(), width/2, height/2);
}

void handleMessage(MuKCastClient client, Message message) {
  image = ((ImageMessage) message).getImage(image);
}

How to install

Download MuKCast library from here.

Unzip and copy it into the libraries folder in the Processing sketchbook. You will need to create this libraries folder if it does not exist.

To find (and change) the Processing sketchbook location on your computer, open the Preferences window from the Processing application (PDE) and look for the "Sketchbook location" item at the top.

By default the following locations are used for your sketchbook folder:

  • For Mac users, the sketchbook folder is located inside ~/Documents/Processing
  • For Windows users, the sketchbook folder is located inside My Documents/Processing

The folder structure for library Console should be as follows:

Processing
  libraries
    MuKCast
      examples
      library
      reference
      src
      library.properties

mukcast's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.