Class: Quark::Quark::Mock::SocketEvent

Inherits:
Object
  • Object
show all
Extended by:
DatawireQuarkCore::Static
Defined in:
lib/quark/mock.rb

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

Constructor Details

#initialize(url, handler) ⇒ SocketEvent

Returns a new instance of SocketEvent.



90
91
92
93
94
95
96
97
# File 'lib/quark/mock.rb', line 90

def initialize(url, handler)
    
    super()
    (self).url = url
    (self).handler = handler

    nil
end

Instance Attribute Details

#expectIdxObject

Returns the value of attribute expectIdx.



83
84
85
# File 'lib/quark/mock.rb', line 83

def expectIdx
  @expectIdx
end

#handlerObject

Returns the value of attribute handler.



83
84
85
# File 'lib/quark/mock.rb', line 83

def handler
  @handler
end

#sockObject

Returns the value of attribute sock.



83
84
85
# File 'lib/quark/mock.rb', line 83

def sock
  @sock
end

#urlObject

Returns the value of attribute url.



83
84
85
# File 'lib/quark/mock.rb', line 83

def url
  @url
end

Instance Method Details

#__init_fields__Object



224
225
226
227
228
229
230
231
232
233
# File 'lib/quark/mock.rb', line 224

def __init_fields__()
    
    super
    self.url = nil
    self.handler = nil
    self.sock = nil
    self.expectIdx = 0

    nil
end

#_getClassObject



180
181
182
183
184
185
# File 'lib/quark/mock.rb', line 180

def _getClass()
    
    return "quark.mock.SocketEvent"

    nil
end

#_getField(name) ⇒ Object



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/quark/mock.rb', line 187

def _getField(name)
    
    if ((name) == ("url"))
        return (self).url
    end
    if ((name) == ("handler"))
        return (self).handler
    end
    if ((name) == ("sock"))
        return (self).sock
    end
    if ((name) == ("expectIdx"))
        return (self).expectIdx
    end
    return nil

    nil
end

#_setField(name, value) ⇒ Object



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/quark/mock.rb', line 206

def _setField(name, value)
    
    if ((name) == ("url"))
        (self).url = ::DatawireQuarkCore.cast(value) { ::String }
    end
    if ((name) == ("handler"))
        (self).handler = ::DatawireQuarkCore.cast(value) { ::Quark.quark.WSHandler }
    end
    if ((name) == ("sock"))
        (self).sock = ::DatawireQuarkCore.cast(value) { ::Quark.quark.mock.MockSocket }
    end
    if ((name) == ("expectIdx"))
        (self).expectIdx = ::DatawireQuarkCore.cast(value) { ::Integer }
    end

    nil
end

#acceptObject



116
117
118
119
120
121
122
123
124
125
# File 'lib/quark/mock.rb', line 116

def accept()
    
    if ((@sock) != (nil))
        ::Quark.quark.concurrent.Context.runtime().fail("already accepted")
    else
        @sock = ::Quark.quark.mock.MockSocket.new(@handler)
    end

    nil
end

#closeObject



134
135
136
137
138
139
# File 'lib/quark/mock.rb', line 134

def close()
    
    (self).sock.close()

    nil
end

#expectBinaryMessageObject



168
169
170
171
172
173
174
175
176
177
178
# File 'lib/quark/mock.rb', line 168

def expectBinaryMessage()
    
    msg = self.expectMessage()
    if (((msg) != (nil)) && (msg.isBinary()))
        return ::DatawireQuarkCore.cast(msg) { ::Quark.quark.mock.BinaryMessage }
    else
        return ::DatawireQuarkCore.cast(nil) { ::Quark.quark.mock.BinaryMessage }
    end

    nil
end

#expectMessageObject



141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/quark/mock.rb', line 141

def expectMessage()
    
    if ((@sock) == (nil))
        ::Quark.quark.concurrent.Context.runtime().fail("not accepted")
    end
    if (::Quark.quark.test.check((@expectIdx) < (((@sock).messages).size), "expected a message"))
        msg = ((@sock).messages)[@expectIdx]
        @expectIdx = (@expectIdx) + (1)
        return msg
    end
    return ::DatawireQuarkCore.cast(nil) { ::Quark.quark.mock.MockMessage }

    nil
end

#expectTextMessageObject



156
157
158
159
160
161
162
163
164
165
166
# File 'lib/quark/mock.rb', line 156

def expectTextMessage()
    
    msg = self.expectMessage()
    if (((msg) != (nil)) && (msg.isText()))
        return ::DatawireQuarkCore.cast(msg) { ::Quark.quark.mock.TextMessage }
    else
        return ::DatawireQuarkCore.cast(nil) { ::Quark.quark.mock.TextMessage }
    end

    nil
end

#getArgsObject



109
110
111
112
113
114
# File 'lib/quark/mock.rb', line 109

def getArgs()
    
    return ::DatawireQuarkCore::List.new([@url, @handler])

    nil
end

#getTypeObject



102
103
104
105
106
107
# File 'lib/quark/mock.rb', line 102

def getType()
    
    return "socket"

    nil
end

#send(message) ⇒ Object



127
128
129
130
131
132
# File 'lib/quark/mock.rb', line 127

def send(message)
    
    @handler.onWSMessage(@sock, message)

    nil
end