Mô hình publish/subscribe theo phòng (room/channel). Sự kiện:
SUB <client> <room>: client đăng ký nhận tin của room.UNSUB <client> <room>: hủy đăng ký.PUB <room> <msg>: phát msg tới mọi subscriber của room, theo thứ tự đăng ký.Mỗi lần phân phối in: <client>: <msg>.
Input:
4
SUB a news
SUB b news
PUB news hello
PUB sport x
Output:
a: hello
b: hello
room sport không có subscriber.
Dòng đầu N. N dòng sự kiện SUB/UNSUB/PUB.
0 ≤ N ≤ 1000. Một client chỉ SUB một room nhiều nhất một lần (nếu đã có thì giữ nguyên).
Với mỗi PUB, in <client>: <msg> cho từng subscriber theo thứ tự đăng ký.
Ví dụ:
Đầu vào:
4
SUB a news
SUB b news
PUB news hello
PUB sport x
Đầu ra:
a: hello
b: hello
Giải thích:
Đang tải editor...