All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.paulgoldbaum.influxdbclient.UdpClient.scala Maven / Gradle / Ivy

There is a newer version: 0.6.1
Show newest version
package com.paulgoldbaum.influxdbclient

import java.net.{InetSocketAddress, DatagramPacket, DatagramSocket}

class UdpClient protected[influxdbclient](host: String, port: Int) {

  val socket = new DatagramSocket()
  val address = new InetSocketAddress(host, port)

  def write(point: Point) = {
    send(point.serialize().getBytes)
  }

  def bulkWrite(points: List[Point]) = {
    send(points.map(_.serialize()).mkString("\n").getBytes)
  }

  private def send(payload: Array[Byte]) = {
    val packet = new DatagramPacket(payload, payload.length, address)
    socket.send(packet)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy