Skip to content

Instantly share code, notes, and snippets.

View darkfrog26's full-sized avatar
🦊
Crazy like a fox

Matt Hicks darkfrog26

🦊
Crazy like a fox
View GitHub Profile
/**
* LiveConnections are created for each window representation of the LivePage. This allows LiveChange lists to be
* trimmed and only include relevant changes for the specific window instance. Reloading a page will reset the
* LiveConnection.
*/
class LiveConnection(created: Long = System.currentTimeMillis(), var lastUpdated: Long = System.currentTimeMillis()) {
private var changes = Vector.empty[LiveChange]
/**
* Retrieves all changes since lastId or Nil if no changes.
package com.projectspeaker.pages
import com.projectspeaker.ProjectSpeakerPage
import org.powerscala.Color
import org.hyperscala.html._
import org.hyperscala.html
import org.hyperscala.html.tag._
import org.powerscala.property._
import org.hyperscala.html.attributes.Target
import org.hyperscala.web.Scope
trait Element
trait Parentable extends Element {
type P = Element
}
trait Childable extends Element {
type C = Element
}
trait Test[T] {
def test[S <: T](value: S): Unit
}
object TestObject extends Test[String] {
private var s: String = _
def test[String](value: String) = {
s = value
}
package test
import collection.mutable.ListBuffer
/**
* @author Matt Hicks <mhicks@powerscala.org>
*/
trait Element
trait Parentable extends Element {
import java.util.UUID
trait Communicator {
def id: UUID
final def send(message: Any) = {
// Sends messages to client
}
def receive(message: Any): Unit
}
case class URL(method: Method = Method.Get,
protocol: String = "http",
host: String = null,
port: Int = 80,
path: String = "/",
parameters: Map[String, List[String]])
sealed class Method(val value: String) extends EnumEntry[Method]
object Method extends Enumerated[Method] {
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
import org.jboss.netty.handler.codec.http.HttpChunk;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.multipart.*;
/**
* HttpUploadHandler provides an easy-to-use abstract handler for parsing multipart form data on the server.
*
package com.outr.webcommunicator.netty.handler
import com.outr.webcommunicator.netty.NettyWebapp
import org.jboss.netty.channel.{MessageEvent, ChannelHandlerContext}
import org.jboss.netty.handler.codec.http.{HttpChunk, HttpRequest}
import org.jboss.netty.handler.codec.http.multipart.{FileUpload, Attribute, DefaultHttpDataFactory, HttpPostRequestDecoder}
import scala.collection.JavaConversions._
/**
import org.jboss.netty.channel.{ChannelFuture, Channel}
import org.jboss.netty.buffer.ChannelBuffers
import org.jboss.netty.util.CharsetUtil
import java.nio.charset.Charset
/**
* @author Matt Hicks <mhicks@outr.com>
*/
class ChannelStringWriter(channel: Channel, buffer: Int = 512, charset: Charset = CharsetUtil.UTF_8) {
private val b = new StringBuilder