Class: Quark::Quark::Mock::MockSocket

Inherits:
DatawireQuarkCore::QuarkObject 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

Methods inherited from DatawireQuarkCore::QuarkObject

#to_s

Constructor Details

#initialize(handler) ⇒ MockSocket

Returns a new instance of MockSocket.



446
447
448
449
450
451
452
453
454
455
456
# File 'lib/quark/mock.rb', line 446

def initialize(handler)
    
    self.__init_fields__
    (self).handler = handler
    (self).closed = false
    (self).messages = ::DatawireQuarkCore::List.new([])
    handler.onWSInit(self)
    handler.onWSConnected(self)

    nil
end

Instance Attribute Details

#closedObject

Returns the value of attribute closed.



438
439
440
# File 'lib/quark/mock.rb', line 438

def closed
  @closed
end

#handlerObject

Returns the value of attribute handler.



438
439
440
# File 'lib/quark/mock.rb', line 438

def handler
  @handler
end

#messagesObject

Returns the value of attribute messages.



438
439
440
# File 'lib/quark/mock.rb', line 438

def messages
  @messages
end

Instance Method Details

#__init_fields__Object



529
530
531
532
533
534
535
536
# File 'lib/quark/mock.rb', line 529

def __init_fields__()
    
    self.messages = ::DatawireQuarkCore::List.new([])
    self.closed = false
    self.handler = nil

    nil
end

#_getClassObject



491
492
493
494
495
496
# File 'lib/quark/mock.rb', line 491

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

    nil
end

#_getField(name) ⇒ Object



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/quark/mock.rb', line 498

def _getField(name)
    
    if ((name) == ("messages"))
        return (self).messages
    end
    if ((name) == ("closed"))
        return (self).closed
    end
    if ((name) == ("handler"))
        return (self).handler
    end
    return nil

    nil
end

#_setField(name, value) ⇒ Object



514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/quark/mock.rb', line 514

def _setField(name, value)
    
    if ((name) == ("messages"))
        (self).messages = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
    end
    if ((name) == ("closed"))
        (self).closed = ::DatawireQuarkCore.cast(value) { ::Object }
    end
    if ((name) == ("handler"))
        (self).handler = ::DatawireQuarkCore.cast(value) { ::Quark.quark.WSHandler }
    end

    nil
end

#closeObject



477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/quark/mock.rb', line 477

def close()
    
    if (@closed)
        ::Quark.quark.concurrent.Context.runtime().fail("already closed")
    else
        @handler.onWSClosed(self)
        @handler.onWSFinal(self)
        @closed = true
    end
    return true

    nil
end

#send(message) ⇒ Object



461
462
463
464
465
466
467
# File 'lib/quark/mock.rb', line 461

def send(message)
    
    (@messages) << (::Quark.quark.mock.TextMessage.new(message))
    return true

    nil
end

#sendBinary(bytes) ⇒ Object



469
470
471
472
473
474
475
# File 'lib/quark/mock.rb', line 469

def sendBinary(bytes)
    
    (@messages) << (::Quark.quark.mock.BinaryMessage.new(bytes))
    return true

    nil
end