hide socket member channel
This commit is contained in:
parent
2edd689ffe
commit
abb63fffe1
|
@ -73,7 +73,7 @@ private[round] final class Socket(
|
|||
|
||||
case Bye(color) => playerDo(color, _.setBye)
|
||||
|
||||
case Ack(uid) => withMember(uid) { _.channel push ackEvent }
|
||||
case Ack(uid) => withMember(uid) { _ push ackEvent }
|
||||
|
||||
case Broom =>
|
||||
broom
|
||||
|
@ -124,10 +124,10 @@ private[round] final class Socket(
|
|||
|
||||
case ChangeFeatured(_, html) =>
|
||||
val msg = makeMessage("featured", Json.obj("html" -> html.toString))
|
||||
watchers.foreach(_.channel push msg)
|
||||
watchers.foreach(_ push msg)
|
||||
|
||||
case UserStartGame(userId, game) => watchers filter (_ onUserTv userId) foreach {
|
||||
_.channel push makeMessage("reloadPage")
|
||||
_ push makeMessage("reloadPage")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,13 +150,13 @@ private[round] final class Socket(
|
|||
|
||||
def batch(member: Member, vevents: List[VersionedEvent]) {
|
||||
if (vevents.nonEmpty) {
|
||||
member.channel push makeMessage("b", vevents map (_ jsFor member))
|
||||
member push makeMessage("b", vevents map (_ jsFor member))
|
||||
}
|
||||
}
|
||||
|
||||
def notifyOwner[A: Writes](color: Color, t: String, data: A) {
|
||||
ownerOf(color) foreach { m =>
|
||||
m.channel push makeMessage(t, data)
|
||||
m push makeMessage(t, data)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ trait Historical[M <: SocketMember, Metadata] { self: SocketActor[M] =>
|
|||
}
|
||||
|
||||
def sendMessage(message:Message)(member: M) {
|
||||
member.channel push {
|
||||
member push {
|
||||
if (shouldSkipMessageFor(message, member)) message.skipMsg
|
||||
else message.fullMsg
|
||||
}
|
||||
|
|
|
@ -75,26 +75,26 @@ abstract class SocketActor[M <: SocketMember](uidTtl: Duration) extends Socket w
|
|||
}
|
||||
|
||||
def notifyAll(msg: JsObject) {
|
||||
members.values.foreach(_.channel push msg)
|
||||
members.values.foreach(_ push msg)
|
||||
}
|
||||
|
||||
def notifyMember[A: Writes](t: String, data: A)(member: M) {
|
||||
member.channel push makeMessage(t, data)
|
||||
member push makeMessage(t, data)
|
||||
}
|
||||
|
||||
def makePong(nb: Int) = makeMessage("n", nb)
|
||||
|
||||
def ping(uid: String) {
|
||||
setAlive(uid)
|
||||
withMember(uid)(_.channel push pong)
|
||||
withMember(uid)(_ push pong)
|
||||
}
|
||||
|
||||
def sendTo(userId: String, msg: JsObject) {
|
||||
memberByUserId(userId) foreach (_.channel push msg)
|
||||
memberByUserId(userId) foreach (_ push msg)
|
||||
}
|
||||
|
||||
def sendTos(userIds: Set[String], msg: JsObject) {
|
||||
membersByUserIds(userIds) foreach (_.channel push msg)
|
||||
membersByUserIds(userIds) foreach (_ push msg)
|
||||
}
|
||||
|
||||
def broom {
|
||||
|
@ -103,7 +103,7 @@ abstract class SocketActor[M <: SocketMember](uidTtl: Duration) extends Socket w
|
|||
|
||||
def eject(uid: String) {
|
||||
withMember(uid) { member =>
|
||||
member.channel.end()
|
||||
member.end
|
||||
quit(uid)
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ abstract class SocketActor[M <: SocketMember](uidTtl: Duration) extends Socket w
|
|||
}
|
||||
|
||||
protected def resyncNow(member: M) {
|
||||
member.channel push resyncMessage
|
||||
member push resyncMessage
|
||||
}
|
||||
|
||||
def addMember(uid: String, member: M) {
|
||||
|
@ -158,7 +158,7 @@ abstract class SocketActor[M <: SocketMember](uidTtl: Duration) extends Socket w
|
|||
"lm" -> move.move
|
||||
))
|
||||
members.values foreach { m =>
|
||||
if (m liveGames move.gameId) m.channel push msg
|
||||
if (m liveGames move.gameId) m push msg
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package lila.socket
|
||||
|
||||
import play.api.libs.json.JsValue
|
||||
|
||||
trait SocketMember extends Ordered[SocketMember] {
|
||||
|
||||
val channel: JsChannel
|
||||
protected val channel: JsChannel
|
||||
val userId: Option[String]
|
||||
val troll: Boolean
|
||||
|
||||
|
@ -16,6 +18,14 @@ trait SocketMember extends Ordered[SocketMember] {
|
|||
def isAuth = userId.isDefined
|
||||
|
||||
def compare(other: SocketMember) = ~userId compare ~other.userId
|
||||
|
||||
def push(msg: JsValue) {
|
||||
channel push msg
|
||||
}
|
||||
|
||||
def end {
|
||||
channel.end
|
||||
}
|
||||
}
|
||||
|
||||
object SocketMember {
|
||||
|
|
Loading…
Reference in a new issue