This file contains hidden or 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
MS4wMzZ8fDEzODAxODQyMzY0OTB8MTExMTExfDYxNzk1ODUyOzIwNTE5NTc5NzsyMDAwOzI7NDcwNzQ7OTstMTstMTswOzA7MDswOzA7MHwzOSwzOSwxMjI2ODk0LDA7NDUsNDUsMTQxMzUwNywwOzE5LDE5LDUyNjg2OCwwOzE1LDE1LDE4NTYxMDMsMDsxMiwxMiw0NTA3Mzk4LDA7MTIsMTIsNjU1MjMwMCwwOzEyLDEyLDE4NTMyNDI2LDA7MTQsMTQsMTYyMzUzOTYwLDA7MCwwLDAsMDswLDAsMCwwO3wzMzYwMTA3NTM0NDUxMTk5OzIyNTE4MDIxNDAxMzk1Njc7MjI1MTc5OTgxNDE3Njc2OTsyMjUxNzk5ODEzNjg1MjU1OzUyNDI4OXwzNTM4MzMzNjUzMTM5OTY3Ozg3OTYxMzUyMjc5Nzc%3D%21END%21 |
This file contains hidden or 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
implicit class Times(val end: Int) extends AnyVal { | |
def times[T, Result](f: => T)(implicit cbf: CanBuildFrom[_, T, Result]): Result = { | |
val builder = cbf() | |
var i = 0 | |
while (i > end) { | |
builder += f | |
i += 1 | |
} | |
builder.result() |
This file contains hidden or 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
trait Context // todo | |
trait DofusMessage // todo | |
object DofusProtocol extends DelimitedTextProtocol("\u0000", "\n\u0000") { | |
def encode(o: Any): Any = o match { | |
case msg: DofusMessage => super.encode(msg.serialize()) | |
case msg: String => super.encode(msg) | |
} | |
def decode(o: Any): Any = super.decode(o) match { |
This file contains hidden or 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
val dataBuilder = StringBuilder.newBuilder | |
session.bufferOption match { | |
case Some(buffer) => | |
dataBuilder ++= buffer.result().mkString | |
buffer.clear() | |
case _ => | |
} | |
o match { |
This file contains hidden or 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
package org.elves | |
import java.nio.charset.Charset | |
import java.nio.{CharBuffer, ByteBuffer} | |
import scala.annotation.tailrec | |
class DelimitedTextProtocol(inputDelimiter: String, outputDelimiter: String, charset: Charset) extends Protocol { | |
def encode(session: Session, o: Any): ByteBuffer = ByteBuffer wrap (o.toString + outputDelimiter).getBytes(charset) | |
def decode(session: Session, buf: ByteBuffer): List[Any] = { |
This file contains hidden or 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
def decode(buf: ByteBuffer): List[Any] = { | |
val msgs = List.newBuilder[Any] | |
var input = charset.decode(buf).toString | |
breakable { | |
while (true) { | |
val index = input.indexOf(inputDelimiter) | |
if (index < 0) break | |
msgs += input.substring(0, index) | |
input = input.substring(index + inputDelimiter.length) |
This file contains hidden or 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
package org.elves | |
import scala.concurrent.{Promise, Future, ExecutionContextExecutorService} | |
import java.nio.channels.{SelectionKey, ServerSocketChannel, Selector} | |
import java.net.SocketAddress | |
import scala.collection.mutable | |
import scala.beans.BeanProperty | |
class TcpService(addr: SocketAddress, executorFactory: () => ExecutionContextExecutorService) extends Service { | |
import JavaConversions.runnable |
This file contains hidden or 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
package backend | |
import ( | |
"fmt" | |
"github.com/Blackrush/gofus/protocol" | |
"io" | |
"math" | |
"time" | |
) |
This file contains hidden or 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
package org.photon.common | |
import java.util.Random | |
object Strings { | |
val alphanum = 'a' to 'z' | |
def rand(implicit rnd: Random): Char = alphanum(rnd.nextInt(alphanum.length)) | |
def rand(n: Int)(implicit rnd: Random): String = (0 to n).foldLeft("") { (res, _) => res + rand } | |
} |
This file contains hidden or 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
if exists("b:did_ftplugin_go_install") | |
finish | |
endif | |
function! GocodeCompletePkg(arg, cmd, index) | |
let s:base=DirName(@%) | |
let s:dirs=filter(split(globpath(s:base, a:arg.'*'), '\n'), 'isdirectory(v:val)') | |
let s:ndirs=len(s:dirs) | |
if s:ndirs <= 0 |