Skip to content

Commit

Permalink
更新: 文件服务器例子
Browse files Browse the repository at this point in the history
  • Loading branch information
davyxu committed May 29, 2018
1 parent 295dd4b commit 1712289
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc/pbcodec.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

* Linux 64位平台,选择 protoc-x.x.x-linux-x86_64.zip

## protoc编译器

确保pb编译器protoc的可执行文件放在GOPATH/bin下


## 安装protoc编译器插件(protoc-gen-gogofaster)

Expand Down
14 changes: 11 additions & 3 deletions examples/fileserver/main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
package main

import (
"flag"
"fmt"
"github.com/davyxu/cellnet"
"github.com/davyxu/cellnet/peer"
_ "github.com/davyxu/cellnet/peer/http"
"github.com/davyxu/cellnet/proc"
_ "github.com/davyxu/cellnet/proc/http"
)

var shareDir = flag.String("share", ".", "folder to share")
var port = flag.Int("port", 9091, "listen port")

func main() {

flag.Parse()

queue := cellnet.NewEventQueue()

p := peer.NewGenericPeer("http.Acceptor", "httpfile", ":9001", nil).(cellnet.HTTPAcceptor)
p.SetFileServe(".", ".")
p := peer.NewGenericPeer("http.Acceptor", "httpfile", fmt.Sprintf(":%d", *port), nil).(cellnet.HTTPAcceptor)
p.SetFileServe(".", *shareDir)

proc.BindProcessorHandler(p, "httpfile", nil)
proc.BindProcessorHandler(p, "http", nil)

p.Start()
queue.StartLoop()
Expand Down

0 comments on commit 1712289

Please sign in to comment.