Socket
Book a DemoInstallSign in
Socket

mooncell

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mooncell

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Mooncell

The Mooncell is a Domain-Driven Design online game server framework inspired by Hanami.rb.

An online game usually includes one or more servers but it is hard to share the codebase and support multiple protocols.

Mooncell split game logic to libs and allow shared with other projects, and allow the developer to implement behaviors inside apps between servers.

Concept

Currently, Mooncell still under design. Below is the core concept to implement servers with it.

Structure

This is a Map server implements a move command.

├── Gemfile
├── Gemfile.lock
├── apps
│   └── map
│       ├── application.rb
│       ├── commands
│       │   └── move.rb
│       ├── config
│       │   └── routes.rb
│       └── responds
│           └── move.rb
└── config
    └── environment.rb

Environment

It defines the shared environment and servers to loaded.

# frozen_string_literal: true

require 'mooncell/protocol/websocket'

require_relative '../apps/map/application'

Mooncell.configure do
  protocol :websocket

  app Map::Application
end

Routes

It defines the command available on the server.

# frozen_string_literal: true

command 'move', 'Map::Commands::Move'

Command

Process the command received from the client.

# frozen_string_literal: true

module Map
  module Commands
    class Move
      include Mooncell::Command

      # Fake Model
      Player = Struct.new(:id, :x, :y)

      # Expose to respond
      expose :player

      def call(params)
        @player = Player.new(params['id'], params['x'], params['y'])
      end
    end
  end
end

Respond

Return the process result to client.

# frozen_string_literal: true

module Map
  module Responds
    class Move
      include Mooncell::Respond

      # Broadcast to all clients
      broadcast true

      def call(*)
        { id: player.id, x: player.x, y: player.y }
      end
    end
  end
end

Installation

TODO

Usage

TODO

Development

TODO

Roadmap

The first target is to design the architecture to support TCP/WebSocket protocol and allow use JSON or customize serializer.

  • Naming
  • Project Generator

TBD

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/elct9620/mooncell. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Code of Conduct

Everyone interacting in the Mooncell project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 31 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.