Class: Quark::MdkProtocol::OpenCloseSubscriber

Inherits:
DatawireQuarkCore::QuarkObject show all
Extended by:
DatawireQuarkCore::Static
Defined in:
lib/mdk_protocol.rb

Overview

Handle Open and Close messages.

Constant Summary

Constants included from DatawireQuarkCore::Static

DatawireQuarkCore::Static::Unassigned

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DatawireQuarkCore::Static

_lazy_statics, static, unlazy_statics

Methods inherited from DatawireQuarkCore::QuarkObject

#to_s

Constructor Details

#initialize(client, node_id, environment) ⇒ OpenCloseSubscriber

Returns a new instance of OpenCloseSubscriber.



1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
# File 'lib/mdk_protocol.rb', line 1072

def initialize(client, node_id, environment)
    
    self.__init_fields__
    (self)._wsclient = client
    (self)._node_id = node_id
    (self)._environment = environment
    (self)._wsclient.subscribe(self)

    nil
end

Instance Attribute Details

#_dispatcherObject

Returns the value of attribute _dispatcher.



1065
1066
1067
# File 'lib/mdk_protocol.rb', line 1065

def _dispatcher
  @_dispatcher
end

#_environmentObject

Returns the value of attribute _environment.



1065
1066
1067
# File 'lib/mdk_protocol.rb', line 1065

def _environment
  @_environment
end

#_node_idObject

Returns the value of attribute _node_id.



1065
1066
1067
# File 'lib/mdk_protocol.rb', line 1065

def _node_id
  @_node_id
end

#_wsclientObject

Returns the value of attribute _wsclient.



1065
1066
1067
# File 'lib/mdk_protocol.rb', line 1065

def _wsclient
  @_wsclient
end

Instance Method Details

#__init_fields__Object



1199
1200
1201
1202
1203
1204
1205
1206
1207
# File 'lib/mdk_protocol.rb', line 1199

def __init_fields__()
    
    self._dispatcher = nil
    self._wsclient = nil
    self._node_id = nil
    self._environment = nil

    nil
end

#_getClassObject



1155
1156
1157
1158
1159
1160
# File 'lib/mdk_protocol.rb', line 1155

def _getClass()
    
    return "mdk_protocol.OpenCloseSubscriber"

    nil
end

#_getField(name) ⇒ Object



1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
# File 'lib/mdk_protocol.rb', line 1162

def _getField(name)
    
    if ((name) == ("_dispatcher"))
        return (self)._dispatcher
    end
    if ((name) == ("_wsclient"))
        return (self)._wsclient
    end
    if ((name) == ("_node_id"))
        return (self)._node_id
    end
    if ((name) == ("_environment"))
        return (self)._environment
    end
    return nil

    nil
end

#_setField(name, value) ⇒ Object



1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
# File 'lib/mdk_protocol.rb', line 1181

def _setField(name, value)
    
    if ((name) == ("_dispatcher"))
        (self)._dispatcher = ::DatawireQuarkCore.cast(value) { ::Quark.mdk_runtime.actors.MessageDispatcher }
    end
    if ((name) == ("_wsclient"))
        (self)._wsclient = ::DatawireQuarkCore.cast(value) { ::Quark.mdk_protocol.WSClient }
    end
    if ((name) == ("_node_id"))
        (self)._node_id = ::DatawireQuarkCore.cast(value) { ::String }
    end
    if ((name) == ("_environment"))
        (self)._environment = ::DatawireQuarkCore.cast(value) { ::Quark.mdk_protocol.OperationalEnvironment }
    end

    nil
end

#onClose(close) ⇒ Object



1148
1149
1150
1151
1152
1153
# File 'lib/mdk_protocol.rb', line 1148

def onClose(close)
    
    (self)._wsclient.onClose((close).error)

    nil
end

#onMessage(origin, message) ⇒ Object



1093
1094
1095
1096
1097
1098
# File 'lib/mdk_protocol.rb', line 1093

def onMessage(origin, message)
    
    ::Quark.mdk_protocol._subscriberDispatch(self, message)

    nil
end

#onMessageFromServer(message) ⇒ Object



1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
# File 'lib/mdk_protocol.rb', line 1107

def onMessageFromServer(message)
    
    type = (::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(message))).id
    if ((type) == ("mdk_protocol.Open"))
        self.onOpen()
        return
    end
    if ((type) == ("mdk_protocol.Close"))
        close = ::DatawireQuarkCore.cast(message) { ::Quark.mdk_protocol.Close }
        self.onClose(close)
        return
    end

    nil
end

#onOpenObject



1141
1142
1143
1144
1145
1146
# File 'lib/mdk_protocol.rb', line 1141

def onOpen()
    
    nil

    nil
end

#onPumpObject



1134
1135
1136
1137
1138
1139
# File 'lib/mdk_protocol.rb', line 1134

def onPump()
    
    nil

    nil
end

#onStart(dispatcher) ⇒ Object



1086
1087
1088
1089
1090
1091
# File 'lib/mdk_protocol.rb', line 1086

def onStart(dispatcher)
    
    (self)._dispatcher = dispatcher

    nil
end

#onStopObject



1100
1101
1102
1103
1104
1105
# File 'lib/mdk_protocol.rb', line 1100

def onStop()
    
    nil

    nil
end

#onWSConnected(websocket) ⇒ Object



1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
# File 'lib/mdk_protocol.rb', line 1123

def onWSConnected(websocket)
    
    open = ::Quark.mdk_protocol.Open.new()
    (open).mdkVersion = "2.0.37"
    (open).nodeId = (self)._node_id
    (open).environment = @_environment
    (self)._dispatcher.tell(self, open.encode(), websocket)

    nil
end