mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 18:27:25 +08:00
Merge pull request #22 from franela/transport_preference
Change connection preferrence so it tries with WS first and the polling
This commit is contained in:
commit
f49f0d8ce0
@ -9,7 +9,11 @@ A live version is available at: http://play-with-docker.com/
|
||||
|
||||
## Requirements
|
||||
|
||||
Docker 1.12.1 or higher is required.
|
||||
Docker 1.13+ is required. You can use docker-machine with the following command:
|
||||
|
||||
```
|
||||
docker-machine create -d virtualbox --virtualbox-boot2docker-url https://github.com/boot2docker/boot2docker/releases/download/v1.13.0-rc1/boot2docker.iso <name>
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
package services
|
||||
|
||||
import "github.com/googollee/go-socket.io"
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/googollee/go-socket.io"
|
||||
)
|
||||
|
||||
type ViewPort struct {
|
||||
Rows uint
|
||||
@ -41,7 +45,10 @@ func NewClient(so socketio.Socket, session *Session) *Client {
|
||||
// Resize all terminals in the session
|
||||
wsServer.BroadcastTo(session.Id, "viewport resize", vp.Cols, vp.Rows)
|
||||
for _, instance := range session.Instances {
|
||||
instance.ResizeTerminal(vp.Cols, vp.Rows)
|
||||
err := instance.ResizeTerminal(vp.Cols, vp.Rows)
|
||||
if err != nil {
|
||||
log.Println("Error resizing terminal", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
so.On("disconnection", func() {
|
||||
|
@ -27,7 +27,7 @@ func GetContainerInfo(id string) (types.ContainerJSON, error) {
|
||||
}
|
||||
|
||||
func CreateNetwork(name string) error {
|
||||
opts := types.NetworkCreate{}
|
||||
opts := types.NetworkCreate{Driver: "overlay", Attachable: true}
|
||||
_, err := c.NetworkCreate(context.Background(), name, opts)
|
||||
|
||||
if err != nil {
|
||||
|
@ -39,11 +39,10 @@ func getDindImageName() string {
|
||||
func NewInstance(session *Session) (*Instance, error) {
|
||||
log.Printf("NewInstance - using image: [%s]\n", dindImage)
|
||||
instance, err := CreateInstance(session.Id, dindImage)
|
||||
instance.Session = session
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
instance.Session = session
|
||||
|
||||
if session.Instances == nil {
|
||||
session.Instances = make(map[string]*Instance)
|
||||
@ -66,8 +65,8 @@ func (s *sessionWriter) Write(p []byte) (n int, err error) {
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func (i *Instance) ResizeTerminal(cols, rows uint) {
|
||||
ResizeExecConnection(i.ExecId, i.Ctx, cols, rows)
|
||||
func (i *Instance) ResizeTerminal(cols, rows uint) error {
|
||||
return ResizeExecConnection(i.ExecId, i.Ctx, cols, rows)
|
||||
}
|
||||
|
||||
func (i *Instance) Exec() {
|
||||
|
@ -42,7 +42,7 @@ func init() {
|
||||
}
|
||||
|
||||
func CreateWSServer() *socketio.Server {
|
||||
server, err := socketio.NewServer(nil)
|
||||
server, err := socketio.NewServer([]string{"websocket", "polling"})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -68,7 +68,7 @@
|
||||
method: 'GET',
|
||||
url: '/sessions/' + $scope.sessionId,
|
||||
}).then(function(response) {
|
||||
var socket = io({path: '/sessions/' + sessionId + '/ws'});
|
||||
var socket = io({path: '/sessions/' + sessionId + '/ws', transports: ['websocket', 'polling']});
|
||||
|
||||
socket.on('terminal out', function(name, data) {
|
||||
var instance = $scope.idx[name];
|
||||
|
Loading…
x
Reference in New Issue
Block a user