Skip LRPCChannel send(), done(), and close() if already closed
This commit is contained in:
parent
368c7333c5
commit
1e627b833e
@ -100,6 +100,7 @@ class LRPCChannel
|
|||||||
# Set self variables
|
# Set self variables
|
||||||
@client = client
|
@client = client
|
||||||
@id = id
|
@id = id
|
||||||
|
@closed = false
|
||||||
# Set function variables to no-ops
|
# Set function variables to no-ops
|
||||||
@onMessage = proc {|fn|}
|
@onMessage = proc {|fn|}
|
||||||
@onClose = proc {}
|
@onClose = proc {}
|
||||||
@ -112,6 +113,7 @@ class LRPCChannel
|
|||||||
# send sends a value on the channel. This should not
|
# send sends a value on the channel. This should not
|
||||||
# be called by the consumer of the channel.
|
# be called by the consumer of the channel.
|
||||||
def send(val)
|
def send(val)
|
||||||
|
return if @closed
|
||||||
fn = @onMessage
|
fn = @onMessage
|
||||||
fn(val)
|
fn(val)
|
||||||
end
|
end
|
||||||
@ -119,6 +121,7 @@ class LRPCChannel
|
|||||||
# done cancels the context corresponding to the channel
|
# done cancels the context corresponding to the channel
|
||||||
# on the server side and closes the channel.
|
# on the server side and closes the channel.
|
||||||
def done()
|
def done()
|
||||||
|
return if @closed
|
||||||
@client.callMethod("lrpc", "ChannelDone", @id)
|
@client.callMethod("lrpc", "ChannelDone", @id)
|
||||||
self.close()
|
self.close()
|
||||||
@client._callMap.delete(@id)
|
@client._callMap.delete(@id)
|
||||||
@ -144,5 +147,6 @@ class LRPCChannel
|
|||||||
def close()
|
def close()
|
||||||
fn = @onClose
|
fn = @onClose
|
||||||
fn()
|
fn()
|
||||||
|
@closed = true
|
||||||
end
|
end
|
||||||
end
|
end
|
Reference in New Issue
Block a user