51 lines
1.1 KiB
Plaintext
51 lines
1.1 KiB
Plaintext
|
|
// P2Pテスト - Box名のみ変更
|
||
|
|
|
||
|
|
print("=== P2P Renamed Boxes Test ===")
|
||
|
|
|
||
|
|
// MessageHub → HubBox に変更
|
||
|
|
box HubBox {
|
||
|
|
init { handlers }
|
||
|
|
|
||
|
|
setup() {
|
||
|
|
print("HubBox setup called")
|
||
|
|
}
|
||
|
|
|
||
|
|
deliver(messageType, data, from) {
|
||
|
|
print("HubBox deliver called")
|
||
|
|
print("Message: " + from + " -> " + messageType + " = " + data)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// PeerNode → NodeBox に変更
|
||
|
|
box NodeBox {
|
||
|
|
init { nodeId, messageHub }
|
||
|
|
|
||
|
|
setup(nodeId, hub) {
|
||
|
|
print("NodeBox setup called")
|
||
|
|
me.nodeId = nodeId
|
||
|
|
me.messageHub = hub
|
||
|
|
print("NodeBox setup completed")
|
||
|
|
}
|
||
|
|
|
||
|
|
send(messageType, data) {
|
||
|
|
print("NodeBox send called")
|
||
|
|
print("About to call messageHub.deliver...")
|
||
|
|
me.messageHub.deliver(messageType, data, me.nodeId)
|
||
|
|
print("NodeBox send completed")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
print("Creating HubBox...")
|
||
|
|
local hub
|
||
|
|
hub = new HubBox()
|
||
|
|
hub.setup()
|
||
|
|
|
||
|
|
print("Creating NodeBox...")
|
||
|
|
local alice
|
||
|
|
alice = new NodeBox()
|
||
|
|
alice.setup("Alice", hub)
|
||
|
|
|
||
|
|
print("Sending message...")
|
||
|
|
alice.send("hello", "Hi there!")
|
||
|
|
|
||
|
|
print("Test completed successfully!")
|