Closed havocp closed 10 years ago
Just saw we have sendRawEvent on UIContext which uses dynamic serialization. In my proposal I'd suggest we delete this. Why would I have access to T but not Writes[T] if I am an sbt plugin working with T and UIContext? I should have the Writes[T].
Values are different because they are sent generically by the task engine, rather than sent by the task itself. The task itself sends events and knows the type statically so can just provide a Writes.
Another aspect of this is https://github.com/sbt/sbt-remote-control/issues/167 - just looked through Protocol.scala and none of the current messages are OK for a plugin or task to send. They are all only for the sbt server engine to send. So CustomEvent really is just TaskEvent or something like that - and task events should probably have their whole own namespace. Sending ExecutionStarted from a task should make a TaskEvent(ExecutionStarted) not a toplevel ExecutionStarted.
The doc comment says SbtClient.dynamicSerialization is for values AND messages. But right now it doesn't look like that's true (the Message trait is sealed and we never look up message Format in dynamicSerialization).
One fix could be:
CustomEvent(name: String, payload: JsValue) extends Event
, where name is the type name we send on the wire and use to find the serializer and payload is everything else from the JsValueJust an initial sketch, not sure how it will play out.