Created
May 13, 2014 20:31
-
-
Save chadselph/f3481bea7eaa9e5ce36a to your computer and use it in GitHub Desktop.
smpp client to test binds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name := "smppeezus" | |
version := "1.0" | |
organization := "me.chadrs" | |
scalaVersion := "2.10.3" | |
libraryDependencies += "akkasmpp" %% "akka-smpp" % "0.1-SNAPSHOT" | |
fork in run := true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.{URL, InetSocketAddress} | |
import javax.sound.sampled.{AudioSystem, LineListener, LineEvent} | |
import scala.concurrent.{Promise, Future, Await} | |
import scala.concurrent.duration.Duration | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import akkasmpp.actors.{SmppClient, SmppClientConfig} | |
import akkasmpp.protocol.{Pdu, BindTransceiverResp, CommandStatus, COctetString, DeliverSm, DeliverSmResp} | |
import akka.actor.ActorSystem | |
import akka.pattern.ask | |
object Smppeezus extends App { | |
val bound2 = new URL("file:///Users/chad/Desktop/boundwav.wav") | |
implicit val actorSystem = ActorSystem("demo") | |
implicit val timeout: akka.util.Timeout = scala.concurrent.duration.Duration(2, "seconds") | |
val server = args(0) | |
val port = Integer.parseInt(args(1)) | |
val client = SmppClient.connect(SmppClientConfig(new InetSocketAddress(server, port)), { | |
case d: DeliverSm => | |
println(s"Got pdu $d") | |
DeliverSmResp(CommandStatus.ESME_ROK, d.sequenceNumber, Some(COctetString.empty)) | |
}, "client") | |
(client ? (SmppClient.Bind("system-id", "pass"))).map { | |
case BindTransceiverResp(CommandStatus.ESME_ROK, _, _, _) => playUrl(bound2) | |
case BindTransceiverResp(_, _, _, _) => println("BIND FAILED!") | |
} | |
def playUrl(url: URL) = { | |
val clip = AudioSystem.getClip() | |
clip.open(AudioSystem.getAudioInputStream(url)) | |
clip.start | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment