GithubHelp home page GithubHelp logo

360t-playercommunication's Introduction

Player Communicator Service

The Player Communicator Service is a Java-based messaging service designed for handling and processing messages between players. It leverages a BlockingQueue to manage incoming messages and provides functionality to process and respond to these messages based on sender and recipient interactions.

Features

  • Asynchronous Message Processing: Utilizes a BlockingQueue to handle incoming messages asynchronously.
  • Sender-Recipient Interaction Tracking: Keeps track of the number of messages exchanged between each sender and recipient pair.
  • Graceful Shutdown: Supports graceful shutdown after processing a maximum number of messages for a given sender-recipient pair.

Getting Started

Prerequisites

  • Java Development Kit (JDK) 8 or higher.
  • An IDE that supports Java (e.g., IntelliJ IDEA, Eclipse).

Installation

  1. Clone the repository to your local machine.
  2. Import the project into your IDE as a Maven or Gradle project, depending on your project setup.
  3. Ensure that your IDE recognizes the src folder as the source root.

Run the code

The code can be run through the following command sh run.sh

  1. This will create a player-communication-1.0-SNAPSHOT.jar file in the target folder.
  2. It will also run the unit test case.
  3. It will finally run the code.

Explanation

Three players are created and they are communicating with each other with the same shared queue. It will send the message back accordingly back to the sender with concatenating the previous message respectively.

Usage

  1. Initialize a BlockingQueue instance with your desired capacity.
  2. Create an instance of MessageProcessor by passing the BlockingQueue to its constructor.
  3. Use the addMessage(Message message) method to add messages to the processing queue.
  4. Start the message processing thread by calling startProcessing(int maxProcessing), where maxProcessing is the maximum number of messages to be processed for a sender-recipient pair before shutting down the service gracefully.

360t-playercommunication's People

Contributors

saad9768 avatar

Watchers

 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.