1
This commit is contained in:
parent
ec16fc1705
commit
81321f5d0c
13
context.go
13
context.go
@ -49,17 +49,13 @@ func (this *Context) GetRemoteAddr() string {
|
||||
return q5.GetRequestRemoteAddr(this.r)
|
||||
}
|
||||
|
||||
/*
|
||||
func (this *Context) Request(name string) *q5.XValue {
|
||||
func (this *Context) Request(name string) string {
|
||||
return q5.Request(this.r, name)
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
func (this *Context) GetBody() *q5.XValue {
|
||||
func (this *Context) GetBody() string {
|
||||
return q5.GetPostBody(this.r)
|
||||
}
|
||||
*/
|
||||
|
||||
func (this *Context) Header(name string) string {
|
||||
if val, ok := this.r.Header[name]; ok {
|
||||
@ -74,10 +70,7 @@ func (this *Context) Response(data string) {
|
||||
}
|
||||
|
||||
func (this *Context)ResponseErr(errCode int32, errMsg string) {
|
||||
/*respObj := q5.NewMxoObject()
|
||||
respObj.SetXValue("errcode", q5.NewXInt32(errCode))
|
||||
respObj.SetXValue("errmsg", q5.NewXString(errMsg))
|
||||
q5.Response(this.w, respObj.ToJsonStr())*/
|
||||
q5.ResponseErr(this.w, errCode, errMsg)
|
||||
}
|
||||
|
||||
func (this *Context) ResponseOk() {
|
||||
|
@ -46,9 +46,8 @@ func (this *HttpServer) Init(serviceName string, logOutputTime int32) *HttpServe
|
||||
logOutputTime,
|
||||
func (ev int32, params *q5.Args) {
|
||||
if ev == q5.TIMER_EXEC_EVENT {
|
||||
/*
|
||||
SysLog().Info("%s maxHandleTime:%d totalRequestTimes:%d okTimes:%d pageNotFoundTimes:%d",
|
||||
params.Sender.GetString(),
|
||||
serviceName,
|
||||
this.maxHandleTime,
|
||||
this.totalRequestTimes,
|
||||
this.okTimes,
|
||||
@ -56,7 +55,6 @@ func (this *HttpServer) Init(serviceName string, logOutputTime int32) *HttpServe
|
||||
this.maxHandleTime = 0
|
||||
this.okTimes = 0
|
||||
this.pageNotFoundTimes = 0
|
||||
*/
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -75,9 +73,8 @@ func (this *HttpServer) Start(listen_port int32) {
|
||||
}
|
||||
|
||||
func (this *HttpServer) dispatchRequest(c *Context) {
|
||||
/*
|
||||
atomic.AddInt64(&this.totalRequestTimes, 1)
|
||||
handleName := c.Request("c").GetString() + "$" + c.Request("a").GetString()
|
||||
handleName := c.Request("c") + "$" + c.Request("a")
|
||||
handle := this.getHandle(handleName)
|
||||
if handle != nil {
|
||||
beginTick := q5.GetTickCount()
|
||||
@ -96,7 +93,7 @@ func (this *HttpServer) dispatchRequest(c *Context) {
|
||||
} else {
|
||||
c.Response(`{"errcode":404, "errmsg":"interface not found"}`)
|
||||
atomic.AddInt64(&this.pageNotFoundTimes, 1)
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
func (this *HttpServer) getHandle(handleName string) HandlerFunc {
|
||||
|
@ -1,14 +0,0 @@
|
||||
package im
|
||||
|
||||
type BaseIMListener struct {
|
||||
}
|
||||
|
||||
|
||||
func (this *BaseIMListener) _IMSocketConnect(msg *IMSocketConnect) {
|
||||
|
||||
}
|
||||
|
||||
func (this *BaseIMListener) _IMSocketDisconnect(msg *IMSocketDisconnect) {
|
||||
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package im
|
||||
|
||||
type IMListener interface {
|
||||
|
||||
_IMSocketConnect(msg *IMSocketConnect)
|
||||
_IMSocketDisconnect(msg *IMSocketDisconnect)
|
||||
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: im_msgid.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package im is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
im_msgid.proto
|
||||
im_proto.proto
|
||||
|
||||
It has these top-level messages:
|
||||
MFTuple
|
||||
IMSocketConnect
|
||||
IMSocketDisconnect
|
||||
*/
|
||||
package im
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
// 消息id定义
|
||||
type IMMessageIdE int32
|
||||
|
||||
const (
|
||||
IMMessageIdE__IMSocketConnect IMMessageIdE = 1
|
||||
IMMessageIdE__IMSocketDisconnect IMMessageIdE = 2
|
||||
)
|
||||
|
||||
var IMMessageIdE_name = map[int32]string{
|
||||
1: "_IMSocketConnect",
|
||||
2: "_IMSocketDisconnect",
|
||||
}
|
||||
var IMMessageIdE_value = map[string]int32{
|
||||
"_IMSocketConnect": 1,
|
||||
"_IMSocketDisconnect": 2,
|
||||
}
|
||||
|
||||
func (x IMMessageIdE) Enum() *IMMessageIdE {
|
||||
p := new(IMMessageIdE)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
func (x IMMessageIdE) String() string {
|
||||
return proto.EnumName(IMMessageIdE_name, int32(x))
|
||||
}
|
||||
func (x *IMMessageIdE) UnmarshalJSON(data []byte) error {
|
||||
value, err := proto.UnmarshalJSONEnum(IMMessageIdE_value, data, "IMMessageIdE")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*x = IMMessageIdE(value)
|
||||
return nil
|
||||
}
|
||||
func (IMMessageIdE) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("im.IMMessageIdE", IMMessageIdE_name, IMMessageIdE_value)
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("im_msgid.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 96 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcb, 0xcc, 0x8d, 0xcf,
|
||||
0x2d, 0x4e, 0xcf, 0x4c, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xca, 0xcc, 0xd5, 0xb2,
|
||||
0xe3, 0xe2, 0xf5, 0xf4, 0xf5, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0xf5, 0x4c, 0x89, 0x4f, 0x15,
|
||||
0x12, 0xe1, 0x12, 0x88, 0xf7, 0xf4, 0x0d, 0xce, 0x4f, 0xce, 0x4e, 0x2d, 0x71, 0xce, 0xcf, 0xcb,
|
||||
0x4b, 0x4d, 0x2e, 0x11, 0x60, 0x14, 0x12, 0xe7, 0x12, 0x86, 0x8b, 0xba, 0x64, 0x16, 0x27, 0x43,
|
||||
0x25, 0x98, 0x00, 0x01, 0x00, 0x00, 0xff, 0xff, 0x15, 0xd2, 0xef, 0x38, 0x54, 0x00, 0x00, 0x00,
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package im;
|
||||
|
||||
//消息id定义
|
||||
enum IMMessageId_e
|
||||
{
|
||||
_IMSocketConnect = 1;
|
||||
_IMSocketDisconnect = 2;
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: im_proto.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
package im
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// 常量
|
||||
type ConstantE int32
|
||||
|
||||
const (
|
||||
ConstantE_MaxIMMsgId ConstantE = 7
|
||||
)
|
||||
|
||||
var ConstantE_name = map[int32]string{
|
||||
7: "MaxIMMsgId",
|
||||
}
|
||||
var ConstantE_value = map[string]int32{
|
||||
"MaxIMMsgId": 7,
|
||||
}
|
||||
|
||||
func (x ConstantE) Enum() *ConstantE {
|
||||
p := new(ConstantE)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
func (x ConstantE) String() string {
|
||||
return proto.EnumName(ConstantE_name, int32(x))
|
||||
}
|
||||
func (x *ConstantE) UnmarshalJSON(data []byte) error {
|
||||
value, err := proto.UnmarshalJSONEnum(ConstantE_value, data, "ConstantE")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*x = ConstantE(value)
|
||||
return nil
|
||||
}
|
||||
func (ConstantE) EnumDescriptor() ([]byte, []int) { return fileDescriptor1, []int{0} }
|
||||
|
||||
type MFTuple struct {
|
||||
Values []string `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
func (m *MFTuple) Reset() { *m = MFTuple{} }
|
||||
func (m *MFTuple) String() string { return proto.CompactTextString(m) }
|
||||
func (*MFTuple) ProtoMessage() {}
|
||||
func (*MFTuple) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} }
|
||||
|
||||
func (m *MFTuple) GetValues() []string {
|
||||
if m != nil {
|
||||
return m.Values
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type IMSocketConnect struct {
|
||||
IsWebsocket *bool `protobuf:"varint,1,opt,name=is_websocket" json:"is_websocket,omitempty"`
|
||||
Host *string `protobuf:"bytes,2,opt,name=host" json:"host,omitempty"`
|
||||
Url *string `protobuf:"bytes,3,opt,name=url" json:"url,omitempty"`
|
||||
QueryStr *string `protobuf:"bytes,4,opt,name=query_str" json:"query_str,omitempty"`
|
||||
Tuples []*MFTuple `protobuf:"bytes,5,rep,name=tuples" json:"tuples,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
func (m *IMSocketConnect) Reset() { *m = IMSocketConnect{} }
|
||||
func (m *IMSocketConnect) String() string { return proto.CompactTextString(m) }
|
||||
func (*IMSocketConnect) ProtoMessage() {}
|
||||
func (*IMSocketConnect) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{1} }
|
||||
|
||||
func (m *IMSocketConnect) GetIsWebsocket() bool {
|
||||
if m != nil && m.IsWebsocket != nil {
|
||||
return *m.IsWebsocket
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *IMSocketConnect) GetHost() string {
|
||||
if m != nil && m.Host != nil {
|
||||
return *m.Host
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *IMSocketConnect) GetUrl() string {
|
||||
if m != nil && m.Url != nil {
|
||||
return *m.Url
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *IMSocketConnect) GetQueryStr() string {
|
||||
if m != nil && m.QueryStr != nil {
|
||||
return *m.QueryStr
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *IMSocketConnect) GetTuples() []*MFTuple {
|
||||
if m != nil {
|
||||
return m.Tuples
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type IMSocketDisconnect struct {
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
func (m *IMSocketDisconnect) Reset() { *m = IMSocketDisconnect{} }
|
||||
func (m *IMSocketDisconnect) String() string { return proto.CompactTextString(m) }
|
||||
func (*IMSocketDisconnect) ProtoMessage() {}
|
||||
func (*IMSocketDisconnect) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MFTuple)(nil), "im.MFTuple")
|
||||
proto.RegisterType((*IMSocketConnect)(nil), "im.IMSocketConnect")
|
||||
proto.RegisterType((*IMSocketDisconnect)(nil), "im.IMSocketDisconnect")
|
||||
proto.RegisterEnum("im.ConstantE", ConstantE_name, ConstantE_value)
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("im_proto.proto", fileDescriptor1) }
|
||||
|
||||
var fileDescriptor1 = []byte{
|
||||
// 204 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x34, 0x8e, 0xbd, 0x4e, 0xc3, 0x30,
|
||||
0x14, 0x46, 0xe5, 0xba, 0xb4, 0xe4, 0xa6, 0x2a, 0x60, 0x75, 0x30, 0x82, 0xc1, 0xca, 0x64, 0x31,
|
||||
0x64, 0xe0, 0x15, 0x8a, 0x90, 0x32, 0x78, 0x82, 0xdd, 0x0a, 0xc1, 0x02, 0x8b, 0xc4, 0x0e, 0xbe,
|
||||
0xd7, 0xfc, 0xbc, 0x3d, 0x8a, 0x81, 0xe5, 0x93, 0xbe, 0xb3, 0x9c, 0x03, 0x7b, 0x3f, 0xd9, 0x39,
|
||||
0x45, 0x8a, 0x6d, 0x59, 0xb1, 0xf2, 0x53, 0x73, 0x09, 0x5b, 0x73, 0xff, 0x98, 0xe7, 0xd1, 0x89,
|
||||
0x3d, 0x6c, 0x3e, 0xfa, 0x31, 0x3b, 0x94, 0x4c, 0x71, 0x5d, 0x35, 0x09, 0xce, 0x3a, 0xf3, 0x10,
|
||||
0x87, 0x37, 0x47, 0xc7, 0x18, 0x82, 0x1b, 0x48, 0x1c, 0x60, 0xe7, 0xd1, 0x7e, 0xba, 0x27, 0x2c,
|
||||
0x58, 0x32, 0xc5, 0xf4, 0xa9, 0xd8, 0xc1, 0xfa, 0x35, 0x22, 0xc9, 0x95, 0x62, 0xba, 0x12, 0x35,
|
||||
0xf0, 0x9c, 0x46, 0xc9, 0xcb, 0xb9, 0x80, 0xea, 0x3d, 0xbb, 0xf4, 0x6d, 0x91, 0x92, 0x5c, 0x17,
|
||||
0x74, 0x05, 0x1b, 0x5a, 0x7c, 0x28, 0x4f, 0x14, 0xd7, 0xf5, 0x6d, 0xdd, 0xfa, 0xa9, 0xfd, 0x6b,
|
||||
0x68, 0x0e, 0x20, 0xfe, 0x9d, 0x77, 0x1e, 0x87, 0x5f, 0xed, 0xcd, 0x35, 0xc0, 0x31, 0x06, 0xa4,
|
||||
0x3e, 0x90, 0x5d, 0x3a, 0xc1, 0xf4, 0x5f, 0x9d, 0x31, 0xf8, 0xd2, 0x3d, 0x9f, 0x6f, 0x7f, 0x02,
|
||||
0x00, 0x00, 0xff, 0xff, 0xef, 0x03, 0x9f, 0xae, 0xd7, 0x00, 0x00, 0x00,
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package im;
|
||||
|
||||
//常量
|
||||
enum Constant_e
|
||||
{
|
||||
MaxIMMsgId = 7;
|
||||
}
|
||||
|
||||
message MFTuple
|
||||
{
|
||||
repeated string values = 1;
|
||||
}
|
||||
|
||||
message IMSocketConnect
|
||||
{
|
||||
optional bool is_websocket = 1;
|
||||
optional string host = 2;
|
||||
optional string url = 3;
|
||||
optional string query_str = 4;
|
||||
repeated MFTuple tuples = 5;
|
||||
}
|
||||
|
||||
message IMSocketDisconnect
|
||||
{
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package im
|
||||
|
||||
import "fmt"
|
||||
|
||||
type IMSender struct {
|
||||
}
|
||||
|
||||
func (this *IMSender) SendMsg(msgid int16, msg interface{}) {
|
||||
fmt.Println("IMSender.SendMsg\n")
|
||||
}
|
||||
|
||||
func (this *IMSender) SendIMSocketConnect(msg *IMSocketConnect) {
|
||||
this.SendMsg(100, msg)
|
||||
}
|
||||
|
||||
func (this *IMSender) SendIMSocketDisconnect(msg *IMSocketDisconnect) {
|
||||
this.SendMsg(100, msg)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user