Class: KRPC::Services::Core

Inherits:
ServiceBase show all
Includes:
Gen::RPCMethodGenerator
Defined in:
lib/krpc/service.rb

Overview

Hardcoded version of ‘krpc` service - The core kRPC service, e.g. for querying for the available services.

Constant Summary

Constants included from KRPC::Streaming::StreamConstructors

KRPC::Streaming::StreamConstructors::STREAM_METHOD_REGEX, KRPC::Streaming::StreamConstructors::STREAM_METHOD_SUFFIX

Constants included from Doc::SuffixMethods

Doc::SuffixMethods::DOCSTRING_SUFFIX, Doc::SuffixMethods::DOCSTRING_SUFFIX_REGEX

Instance Attribute Summary

Attributes inherited from ServiceBase

#client

Instance Method Summary collapse

Methods included from Gen::RPCMethodGenerator

#include_rpc_method

Methods included from KRPC::Streaming::StreamConstructors

included, #method_missing, #respond_to_missing?

Methods included from Doc::SuffixMethods

included, #method_missing, #respond_to_missing?

Constructor Details

#initialize(client) ⇒ Core

Returns a new instance of Core.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/krpc/service.rb', line 63

def initialize(client)
  super(client)
  unless respond_to? :get_status
    # Generate enumerations
    TypeStore[PB::Type.new(code: :ENUMERATION, service: 'Core', name: 'GameScene')].set_values(
      Encoder.hash_to_enumeration_values(
        space_center: 0, flight: 1, tracking_station: 2, editor_vab: 3, editor_sph: 4
      )
    )

    # Generate procedures
    opts = {doc_service_name: 'Core'}

    include_rpc_method 'KRPC', 'GetStatus',
                       return_type: PB::Type.new(code: :STATUS),
                       xmldoc: "<doc>\n<summary>\nReturns some information about the server, such as the version.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'GetServices',
                       return_type: PB::Type.new(code: :SERVICES),
                       xmldoc: "<doc>\n<summary>\nReturns information on all services, procedures, classes, properties etc. provided by the server.\nCan be used by client libraries to automatically create functionality such as stubs.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'AddStream',
                       params: [
                         PB::Parameter.new(name: 'call', type: PB::Type.new(code: :PROCEDURE_CALL)),
                         PB::Parameter.new(name: 'start', type: PB::Type.new(code: :BOOL), default_value: "\x01")
                       ],
                       return_type: PB::Type.new(code: :STREAM),
                       xmldoc: "<doc>\n<summary>\nAdd a streaming request and return its identifier.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'StartStream',
                       params: [PB::Parameter.new(name: 'id', type: PB::Type.new(code: :UINT64))],
                       xmldoc: "<doc>\n<summary>\nStart a previously added streaming request.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'SetStreamRate',
                       params: [
                         PB::Parameter.new(name: 'id', type: PB::Type.new(code: :UINT64)),
                         PB::Parameter.new(name: 'rate', type: PB::Type.new(code: :FLOAT))
                       ],
                       xmldoc: "<doc>\n<summary>\nSet the update rate for a stream in Hz.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'RemoveStream',
                       params: [PB::Parameter.new(name: 'id', type: PB::Type.new(code: :UINT64))],
                       xmldoc: "<doc>\n<summary>\nRemove a streaming request.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'get_Clients',
                       return_type: PB::Type.new(code: :LIST, types: [PB::Type.new(code: :TUPLE, types: [PB::Type.new(code: :BYTES), PB::Type.new(code: :STRING), PB::Type.new(code: :STRING)])]),
                       xmldoc: "<doc>\n<summary>\nA list of RPC clients that are currently connected to the server.\nEach entry in the list is a clients identifier, name and address.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'get_CurrentGameScene',
                       return_type: PB::Type.new(code: :ENUMERATION, service: 'Core', name: 'GameScene'),
                       xmldoc: "<doc>\n<summary>\nGet the current game scene.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'GetClientID',
                       return_type: PB::Type.new(code: :BYTES),
                       xmldoc: "<doc>\n<summary>\nReturns the identifier for the current client.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'GetClientName',
                       return_type: PB::Type.new(code: :STRING),
                       xmldoc: "<doc>\n<summary>\nReturns the name of the current client.\nThis is an empty string if the client has no name.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'get_Paused',
                       return_type: PB::Type.new(code: :BOOL),
                       xmldoc: "<doc>\n<summary>\nWhether the game is paused.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'set_Paused',
                       params: [PB::Parameter.new(name: 'value', type: PB::Type.new(code: :BOOL))],
                       xmldoc: "<doc>\n<summary>\nWhether the game is paused.\n</summary>\n</doc>",
                       **opts
    include_rpc_method 'KRPC', 'AddEvent',
                       params: [PB::Parameter.new(name: 'expression', type: PB::Type.new(code: :CLASS, service: 'KRPC', name: 'Expression'))],
                       return_type: PB::Type.new(code: :EVENT),
                       xmldoc: "<doc>\n<summary>\nCreate an event from a server side expression.\n</summary>\n</doc>",
                       **opts
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class KRPC::Streaming::StreamConstructors