Work around scodec-akka bug and remove old UDP packet

This commit is contained in:
Chord 2016-06-04 03:15:27 -04:00
parent 8b8194cb44
commit c18ec5c6ba
2 changed files with 4 additions and 5 deletions

View file

@ -56,9 +56,6 @@ class SessionRouter(pipeline : List[SessionPipeline]) extends Actor with MDCCont
def initializing : Receive = {
case Hello() =>
inputRef = sender()
inputRef ! SendPacket(hex"41414141", new InetSocketAddress("8.8.8.8", 51000))
context.become(started)
case default =>
log.error(s"Unknown message $default. Stopping...")

View file

@ -4,8 +4,9 @@ import java.net.{InetAddress, InetSocketAddress}
import akka.actor.SupervisorStrategy.{Restart, Stop}
import akka.actor.{Actor, ActorRef, OneForOneStrategy, Props, Terminated}
import akka.io._
import scodec.bits.ByteVector
import scodec.bits._
import scodec.interop.akka._
import akka.util.ByteString
final case class ReceivedPacket(msg : ByteVector, from : InetSocketAddress)
final case class SendPacket(msg : ByteVector, to : InetSocketAddress)
@ -40,7 +41,8 @@ class UdpListener(nextActorProps : Props, nextActorName : String, address : Inet
def ready(socket: ActorRef): Receive = {
case SendPacket(msg, to) =>
bytesSent += msg.size
socket ! Udp.Send(msg.toByteString, to)
// XXX: revert back to msg.toByteString when scodec-akka is unbroken... (this is doing a copy)
socket ! Udp.Send(ByteString(msg.toByteBuffer), to)
case Udp.Received(data, remote) =>
bytesRecevied += data.size
nextActor ! ReceivedPacket(data.toByteVector, remote)