Skip to content
Mo Morsi edited this page Feb 4, 2014 · 7 revisions

Clients

# Interacting with the simulation There are many other ways to query and control an Omega simulation other than the Web frontend

bin/util

Many various utilities to server many various purposes

bin/util/omega-cosmos-retrieve

Query cosmos galaxies,systems,other entities by id or name

bin/util/omega-console

Interactive Pry based console which to query and manipulate omega entities

bin/util/omega-monitor

Ncurses bases interface which to view overall simulation stats which periodically refresh

bin/util/omega-status

Display a slew of debugging information and simulation statistics. Requires the omega-server to be running in debugging mode to work.

bin/util/omega-mission-assign

Assigns a mission to a specified user

# Omega Client Omega provides a full object orientated Ruby client interface which to transparently query and manipulate server side entities through Ruby classes.

Basic usage allows the user to retrieve and store entities, automatically updating them upon server-side state changes, and invoking simple commands remotely.

Advanced features incorporate various algorithms to seek and move to various targets and perform operations such as mining/attacking/construction upon arrival.

See the Client Documentation for complete usage.

# Omega Client DSL Omega also provides a rich dsl which to quickly setup and manipulate simulations from human-friendly scripts.

See the Client DSL Documentation for complete usage.

require 'omega/client/dsl'

login 'admin', 'secret'

galaxy 'Zeus' do |g|
  system 'Athena', 'HR1925', :location => rand_location(:max => SIZE) do |sys|
    asteroid gen_uuid, :location => rand_location(:max => SIZE) do |ast|
      resource :resource => rand_resource, :quantity => 5000
    end
  end
end

user 'player', 'reyalp' do |u|
  role :regular_user
end

ship =
  ship("player-miner1") do |ship|
    ship.type = :mining
    ship.user_id = 'player'
    ship.solar_system = system('Athena')
    ship.location = rand_location(:max => SIZE)
  end

dock(ship.id, station('player-station1').id)
# etc...

examples/*

The omega client interface and dsl are used in various scripts in the examples/ directory. These are all self contained and may be easily copied by the end user and adapted to serve any purpose.

curl

Omega can be invoked over curl like so

$ curl -X POST http://localhost:8888 -d \
  '{"jsonrpc":"2.0", "method":"cosmos::get_entities",
    "params":["of_type", "Cosmos::SolarSystem"], "id":"123"}'

  => {"jsonrpc":"2.0","id":"123","result":[{"json_class":"Cosmos::SolarSystem","data":{"name":"..."}}]}

For this example auth has been disabled by setting 'user_perms_enabled' to false in omega.yml. If enabled, a user can send a request to 'users::login' with valid credentials to retrieve a session id.

Set this session id in the json of subsequent rpc requests (at the top level at the same scope as the 'jsonrpc' and 'method' keys) to authenticate them from here on out.

# Other Any language that has a [json-rpc client](http://en.wikipedia.org/wiki/JSON-RPC#Implementations) library should be able to invoke omega methods easily by sending requests for the [Omega JSON-RPC Methods](.#json-rpc-api), see specific methods for more details regarding parameter lists, errors thrown, and return values. #JSON-RPC API The complete Omega JSON-RPC API can be seen [here](https://github.com/movitto/omega/blob/master/API).

Most public methods other than registration / login related ones require an authenticated session potentionally with additional privs ontop of that (specific to the method being invoked and data its being invoked with).

Private methods can only be invoked by internal subsystems or by privileged users.

#CallbackEvents Various methods in the Omega JSON-RPC API register the client to server-side callbacks which will be periodically invoked at intervals specified by the method parameters.

For example invoking "motel::track_movement, <location_id>, " will subscribe the client to notifications whenever the location moves the specified distance.

The client receives these via json-rpc notifications to corresponding callback methods such as "motel::on_movement, , ".

Invoking these methods must be done over an interface which supports persistant connections, for example TCP, Web Sockets, or AMQP. HTTP will not work for these callbacks (currently).

See the JSON-RPC API for server and client side callback methods.

Clone this wiki locally