Rohan Sircar
4 years ago
9 changed files with 251 additions and 41 deletions
-
5build.sbt
-
14src/main/resources/fxml/Chat.fxml
-
4src/main/resources/logback.xml
-
6src/main/scala/wow/doge/chatto/ApplicationController.scala
-
12src/main/scala/wow/doge/chatto/control/UserBox2.scala
-
129src/main/scala/wow/doge/chatto/controller/ChatController.scala
-
8src/main/scala/wow/doge/chatto/controller/LoginController.scala
-
69src/main/scala/wow/doge/chatto/service/CustomSerializer.scala
-
45src/main/scala/wow/doge/chatto/service/UserService.scala
@ -0,0 +1,12 @@ |
|||
package wow.doge.chatto.control |
|||
|
|||
import javafx.scene.layout.HBox |
|||
import javafx.scene.control.Label |
|||
import scalafx.Includes._ |
|||
|
|||
class UserBox2(_username: String) extends HBox() { |
|||
val usernameLabel = new Label(_username) |
|||
this.children ++= Seq { |
|||
usernameLabel |
|||
} |
|||
} |
@ -0,0 +1,69 @@ |
|||
package wow.doge.chatto.service |
|||
|
|||
import org.json4s.CustomSerializer |
|||
import org.json4s._ |
|||
import java.time.Instant |
|||
// import org.json4s.JsonAST._ |
|||
import org.json4s.JsonDSL._ |
|||
// class ParentSerializer extends Serializer[Parent] { |
|||
// private val ParentClass = classOf[Parent] |
|||
// implicit val formats = DefaultFormats |
|||
|
|||
// def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), Parent] = { |
|||
// case (TypeInfo(ParentClass, _), json) => json match { |
|||
// case JObject(JField("kind", JString(kind)) :: _) => kind match { |
|||
// case "first_type" => json.extract[ChildClassOne] |
|||
// case "second_type" => json.extract[ChildClassTwo] |
|||
// } |
|||
|
|||
// case _ => throw new MappingException("Invalid kind") |
|||
// } |
|||
// } |
|||
|
|||
// def serialize(implicit format: Formats): PartialFunction[Any, JValue] = Map() |
|||
// } |
|||
|
|||
// class MyJInstantSerializer extends Serializer[Instant] { |
|||
// implicit val formats = DefaultFormats |
|||
|
|||
// def deserialize( |
|||
// implicit format: Formats |
|||
// ): PartialFunction[(TypeInfo, JValue), Instant] = { |
|||
// case (_, JString(d)) => Instant.parse(d) |
|||
// case (_, JNull) => null |
|||
// } |
|||
|
|||
// def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { |
|||
// case d: Instant => JString(d.toString()) |
|||
// } |
|||
// } |
|||
|
|||
// class MyJInstantSerializer |
|||
// extends CustomSerializer[Instant](implicit format => |
|||
// ( |
|||
// { |
|||
// // case JInt(d) => Instant.ofEpochMilli(d.toLong) |
|||
// case JString(d) => Instant.parse(d) |
|||
// case JNull => null |
|||
// }, { |
|||
// // case d: Instant => JInt(d.toEpochMilli) |
|||
// case d: Instant => JString(d.toString()) |
|||
// } |
|||
// ) |
|||
// ) |
|||
// import java.time.ZonedDateTime |
|||
// import java.time.format.DateTimeFormatter |
|||
|
|||
// a custom serializer has two partial functions, one |
|||
// for serializing and one for deserializing |
|||
// case object ZDTSerializer |
|||
// extends CustomSerializer[ZonedDateTime](format => |
|||
// ({ |
|||
// case JString(s) => ZonedDateTime.parse(s) |
|||
// }, { |
|||
// case zdt: ZonedDateTime => |
|||
// JString( |
|||
// zdt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX")) |
|||
// ) |
|||
// }) |
|||
// ) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue