本文整理汇总了Golang中gk/gkerr.GenGkErr函数的典型用法代码示例。如果您正苦于以下问题:Golang GenGkErr函数的具体用法?Golang GenGkErr怎么用?Golang GenGkErr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GenGkErr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getMaxChatId
func (gkDbCon *GkDbConDef) getMaxChatId() (int32, *gkerr.GkErrDef) {
var stmt *sql.Stmt
var maxId int32 = 0
var err error
stmt, err = gkDbCon.sqlDb.Prepare("select max(id) from chat_archives")
if err != nil {
return 0, gkerr.GenGkErr("sql.Prepare"+getDatabaseErrorMessage(err), err, ERROR_ID_PREPARE)
}
defer stmt.Close()
var rows *sql.Rows
rows, err = stmt.Query()
if err != nil {
return 0, gkerr.GenGkErr("stmt.Query"+getDatabaseErrorMessage(err), err, ERROR_ID_QUERY)
}
defer rows.Close()
if rows.Next() {
err = rows.Scan(&maxId)
if err != nil {
return 0, gkerr.GenGkErr("rows.Scan"+getDatabaseErrorMessage(err), err, ERROR_ID_ROWS_SCAN)
}
}
return maxId, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:30,代码来源:chatArchives.go
示例2: substituteOneAttributeId
// this assumes that the space is called xlink for
// xmlns:xlink="http://www.w3.org/1999/xlink"
func substituteOneAttributeId(idMap map[string]string, space string, name string, value string) (string, *gkerr.GkErrDef) {
var returnValue string = value
var ok bool
var gkErr *gkerr.GkErrDef
switch name {
case "style":
if space == "" {
var id string
id, gkErr = getFillIdOutOfStyle(value)
if gkErr != nil {
return "", gkErr
}
if id != "" {
var newId string
newId, ok = idMap[id]
if !ok {
gkErr = gkerr.GenGkErr("could not find id in idMap "+id, nil, ERROR_ID_INTERNAL_ID_MAP)
return "", gkErr
}
returnValue = strings.Replace(returnValue, "fill:url(#"+id+")", "fill:url(#"+newId+")", 1)
}
id, gkErr = getFilterIdOutOfStyle(value)
if gkErr != nil {
return "", gkErr
}
if id != "" {
var newId string
newId, ok = idMap[id]
if !ok {
gkErr = gkerr.GenGkErr("could not find id in idMap "+id, nil, ERROR_ID_INTERNAL_ID_MAP)
return "", gkErr
}
returnValue = strings.Replace(returnValue, "filter:url(#"+id+")", "filter:url(#"+newId+")", 1)
}
}
case "href":
if space == "xlink" {
var id string
var newId string
id, gkErr = getIdOutOfHref(value)
if gkErr != nil {
return "", gkErr
}
newId, ok = idMap[id]
if !ok {
gkErr = gkerr.GenGkErr("could not find id in idMap "+id, nil, ERROR_ID_INTERNAL_ID_MAP)
return "", gkErr
}
returnValue = strings.Replace(value, "#"+id, "#"+newId, 1)
}
}
return returnValue, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:62,代码来源:gksvg.go
示例3: GetContextUser
// no error return if row is not found
func (gkDbCon *GkDbConDef) GetContextUser(userName string) (*DbContextUserDef, bool, *gkerr.GkErrDef) {
var stmt *sql.Stmt
var err error
var dbContextUser *DbContextUserDef = new(DbContextUserDef)
var rowFound bool
stmt, err = gkDbCon.sqlDb.Prepare("select context_users.id, context_users.last_position_x, context_users.last_position_y, context_users.last_position_z, context_users.last_pod from users, context_users where users.id = context_users.id and users.user_name = $1")
if err != nil {
return nil, false, gkerr.GenGkErr("sql.Prepare"+getDatabaseErrorMessage(err), err, ERROR_ID_PREPARE)
}
defer stmt.Close()
var rows *sql.Rows
rows, err = stmt.Query(userName)
if err != nil {
return nil, false, gkerr.GenGkErr("stmt.Query"+getDatabaseErrorMessage(err), err, ERROR_ID_QUERY)
}
defer rows.Close()
if rows.Next() {
err = rows.Scan(&dbContextUser.id, &dbContextUser.LastPositionX, &dbContextUser.LastPositionY, &dbContextUser.LastPositionZ, &dbContextUser.LastPod)
if err != nil {
return nil, false, gkerr.GenGkErr("rows.Scan"+getDatabaseErrorMessage(err), err, ERROR_ID_ROWS_SCAN)
}
rowFound = true
} else {
rowFound = false
}
return dbContextUser, rowFound, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:35,代码来源:users.go
示例4: getNextChatArchivesId
func (gkDbCon *GkDbConDef) getNextChatArchivesId() (int32, *gkerr.GkErrDef) {
var stmt *sql.Stmt
var err error
stmt, err = gkDbCon.sqlDb.Prepare("select nextval('chat_archives_seq')")
if err != nil {
return 0, gkerr.GenGkErr("sql.Prepare"+getDatabaseErrorMessage(err), err, ERROR_ID_PREPARE)
}
defer stmt.Close()
var rows *sql.Rows
rows, err = stmt.Query()
if err != nil {
return 0, gkerr.GenGkErr("stmt.Query"+getDatabaseErrorMessage(err), err, ERROR_ID_QUERY)
}
defer rows.Close()
var id int32
if rows.Next() {
err = rows.Scan(&id)
if err != nil {
return 0, gkerr.GenGkErr("rows.Scan"+getDatabaseErrorMessage(err), err, ERROR_ID_ROWS_SCAN)
}
} else {
return 0, gkerr.GenGkErr("select users", nil, ERROR_ID_NO_ROWS_FOUND)
}
return id, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:33,代码来源:chatArchives.go
示例5: GetFileContents
func GetFileContents(fileName string) ([]byte, *gkerr.GkErrDef) {
var file *os.File
var err error
var gkErr *gkerr.GkErrDef
var data []byte = make([]byte, 0, 0)
file, err = os.Open(fileName)
if err != nil {
gkErr = gkerr.GenGkErr("os.Open file: "+fileName, err, ERROR_ID_OPEN_FILE)
return nil, gkErr
}
defer file.Close()
buf := make([]byte, 1024, 1024)
var readCount int
for {
readCount, err = file.Read(buf)
if readCount > 0 {
data = append(data, buf[0:readCount]...)
}
if err != nil {
if err == io.EOF {
break
}
gkErr = gkerr.GenGkErr("file.Read file: "+fileName, err, ERROR_ID_READ_FILE)
return nil, gkErr
}
}
return data, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:33,代码来源:gkFile.go
示例6: GetPodsList
func (gkDbCon *GkDbConDef) GetPodsList() ([]DbPodDef, *gkerr.GkErrDef) {
var stmt *sql.Stmt
var err error
var dbPodsList []DbPodDef = make([]DbPodDef, 0, 0)
stmt, err = gkDbCon.sqlDb.Prepare("select id, pod_title from pods")
if err != nil {
return nil, gkerr.GenGkErr("sql.Prepare"+getDatabaseErrorMessage(err), err, ERROR_ID_PREPARE)
}
defer stmt.Close()
var rows *sql.Rows
rows, err = stmt.Query()
if err != nil {
return nil, gkerr.GenGkErr("stmt.Query"+getDatabaseErrorMessage(err), err, ERROR_ID_QUERY)
}
defer rows.Close()
for rows.Next() {
var dbPod DbPodDef
err = rows.Scan(&dbPod.Id, &dbPod.Title)
if err != nil {
return nil, gkerr.GenGkErr("rows.Scan"+getDatabaseErrorMessage(err), err, ERROR_ID_ROWS_SCAN)
}
dbPodsList = append(dbPodsList, dbPod)
}
return dbPodsList, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:32,代码来源:pods.go
示例7: GetUser
// return error if row not found
func (gkDbCon *GkDbConDef) GetUser(userName string) (*DbUserDef, *gkerr.GkErrDef) {
var stmt *sql.Stmt
var err error
var dbUser *DbUserDef = new(DbUserDef)
stmt, err = gkDbCon.sqlDb.Prepare("select id, user_name, password_hash, password_salt, email, account_creation_date, last_login_date from users where user_name = $1")
if err != nil {
return nil, gkerr.GenGkErr("sql.Prepare"+getDatabaseErrorMessage(err), err, ERROR_ID_PREPARE)
}
defer stmt.Close()
var rows *sql.Rows
rows, err = stmt.Query(userName)
if err != nil {
return nil, gkerr.GenGkErr("stmt.Query"+getDatabaseErrorMessage(err), err, ERROR_ID_QUERY)
}
defer rows.Close()
if rows.Next() {
err = rows.Scan(&dbUser.id, &dbUser.UserName, &dbUser.PasswordHash, &dbUser.PasswordSalt, &dbUser.Email, &dbUser.accountCreationDate, &dbUser.lastLoginDate)
if err != nil {
return nil, gkerr.GenGkErr("rows.Scan"+getDatabaseErrorMessage(err), err, ERROR_ID_ROWS_SCAN)
}
} else {
return nil, gkerr.GenGkErr("select users", nil, ERROR_ID_NO_ROWS_FOUND)
}
return dbUser, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:33,代码来源:users.go
示例8: AddNewUser
func (gkDbCon *GkDbConDef) AddNewUser(userName string, passwordHash string, passwordSalt string, email string) *gkerr.GkErrDef {
var stmt *sql.Stmt
var err error
var id int64
var gkErr *gkerr.GkErrDef
id, gkErr = gkDbCon.getNextUsersId()
if gkErr != nil {
return gkErr
}
stmt, err = gkDbCon.sqlDb.Prepare("insert into users (id, user_name, password_hash, password_salt, email, account_creation_date, last_login_date) values ($1, $2, $3, $4, $5, $6, $7)")
if err != nil {
return gkerr.GenGkErr("stmt.Prepare"+getDatabaseErrorMessage(err), err, ERROR_ID_PREPARE)
}
defer stmt.Close()
var accountCreationDate time.Time = time.Now()
var lastLoginDate time.Time = time.Now()
_, err = stmt.Exec(id, userName, passwordHash, passwordSalt, email, accountCreationDate, lastLoginDate)
if err != nil {
if isUniqueViolation(err) {
return gkerr.GenGkErr("stmt.Exec unique violation", err, ERROR_ID_UNIQUE_VIOLATION)
}
return gkerr.GenGkErr("stmt.Exec"+getDatabaseErrorMessage(err), err, ERROR_ID_EXECUTE)
}
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:33,代码来源:users.go
示例9: rebuildSvg
func rebuildSvg(node *nodeDef, buf io.Writer) *gkerr.GkErrDef {
var gkErr *gkerr.GkErrDef
var result []byte = make([]byte, 0, 128)
var err error
result = append(result, '<')
if node.nameSpace != "" {
result = append(result, []byte(node.nameSpace)...)
result = append(result, ':')
}
result = append(result, []byte(node.nameLocal)...)
for _, attribute := range node.attributeList {
result = append(result, ' ')
if attribute.nameSpace != "" {
if attribute.nameSpace == "http://www.w3.org/XML/1998/namespace" {
result = append(result, []byte("xml")...)
} else {
result = append(result, []byte(attribute.nameSpace)...)
}
result = append(result, ':')
}
result = append(result, []byte(fmt.Sprintf("%s=\"%s\"", attribute.nameLocal, escapeXML([]byte(attribute.value))))...)
}
result = append(result, '>')
_, err = buf.Write(result)
if err != nil {
gkErr = gkerr.GenGkErr("write fix svg results", err, ERROR_ID_WRITE_SVG)
return gkErr
}
for _, childNode := range node.childList {
gkErr = rebuildSvg(childNode, buf)
}
result = make([]byte, 0, 16)
if !isCharDataAllWhiteSpace(node.charData) {
result = append(result, node.charData...)
}
result = append(result, []byte("</")...)
if node.nameSpace != "" {
result = append(result, []byte(node.nameSpace)...)
result = append(result, ':')
}
result = append(result, []byte(node.nameLocal)...)
result = append(result, '>')
_, err = buf.Write(result)
if err != nil {
gkErr = gkerr.GenGkErr("write fix svg results", err, ERROR_ID_WRITE_SVG)
return gkErr
}
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:57,代码来源:gksvg.go
示例10: SendEmail
func SendEmail(address string, from string, toArray []string, subject string, message []byte) (string, *gkerr.GkErrDef) {
var err error
var conn *smtp.Client
var dataWriter io.WriteCloser
var gkErr *gkerr.GkErrDef
var sendId string
conn, err = smtp.Dial(address)
if err != nil {
gkErr = gkerr.GenGkErr("smtp.Dial", err, ERROR_ID_SMTP_DIAL)
return "", gkErr
}
conn.Mail(from)
for _, adr := range toArray {
conn.Rcpt(adr)
}
dataWriter, err = conn.Data()
if err != nil {
gkErr = gkerr.GenGkErr("conn.Data", err, ERROR_ID_SMTP_DATA)
return "", gkErr
}
defer dataWriter.Close()
buf := bytes.NewBufferString("From: " + from + "\nTo: " + toArray[0] + "\nSubject: " + subject + "\n")
_, err = buf.WriteTo(dataWriter)
if err != nil {
gkErr = gkerr.GenGkErr("buf.WriteTo", err, ERROR_ID_SMTP_WRITE)
return "", gkErr
}
buf = bytes.NewBufferString(string(message))
_, err = buf.WriteTo(dataWriter)
if err != nil {
gkErr = gkerr.GenGkErr("buf.WriteTo", err, ERROR_ID_SMTP_WRITE)
return "", gkErr
}
err = conn.Quit()
if err != nil {
localError := fmt.Sprintf("%v", err)
if strings.Index(localError, "Ok") != -1 &&
strings.Index(localError, "queued as") != -1 {
sendId = localError
} else {
gkErr = gkerr.GenGkErr("conn.Quit", err, ERROR_ID_SMTP_QUIT)
//gklog.LogTrace(fmt.Sprintf("smtp quit %T [%v] %v",err, err, gkErr))
return "", gkErr
}
}
return sendId, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:56,代码来源:gkNetEmail.go
示例11: NewTemplate
func NewTemplate(templateDir string, templateName string) (*TemplateDef, *gkerr.GkErrDef) {
var gkTemplate *TemplateDef = new(TemplateDef)
gkTemplate.tmpl = template.New(templateName)
var file *os.File
var templateListFileName string
var err error
templateListFileName = templateDir + string(os.PathSeparator) + templateName + ".txt"
file, err = os.Open(templateListFileName)
if err != nil {
return nil, gkerr.GenGkErr("os.Open", err, ERROR_ID_OPEN_TEMPLATE_LIST)
}
defer file.Close()
var br *bufio.Reader
localFileNames := make([]string, 0, 0)
br = bufio.NewReader(file)
for {
var line string
line, err = br.ReadString('\n')
line = strings.Trim(line, "\r\n\t ")
if line != "" {
localFileNames = append(localFileNames, templateDir+string(os.PathSeparator)+line)
}
if err != nil {
if err == io.EOF {
break
}
return nil, gkerr.GenGkErr("br.ReadString", err, ERROR_ID_READ_TEMPLATE_LIST)
}
}
// localFileNames = make([]string, len(fileNames), len(fileNames))
// for i := 0; i < len(fileNames); i++ {
// localFileNames[i] = templateDir + string(os.PathSeparator) + fileNames[i] + ".html"
// }
gklog.LogTrace(fmt.Sprintf("localFileNames: %+v", localFileNames))
_, err = gkTemplate.tmpl.ParseFiles(localFileNames...)
if err != nil {
return nil, gkerr.GenGkErr("tmpl.ParseFiles", err, ERROR_ID_PARSE_FILES)
}
return gkTemplate, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:55,代码来源:gkTmpl.go
示例12: GetLastChatArchiveEntries
// return error if row not found
// this could be improved by saving recent "id" values
func (gkDbCon *GkDbConDef) GetLastChatArchiveEntries(count int) ([]LugChatArchiveDef, *gkerr.GkErrDef) {
var stmt *sql.Stmt
var err error
var results []LugChatArchiveDef = make([]LugChatArchiveDef, 0, count)
var gkErr *gkerr.GkErrDef
var maxId int32
var startId int32 = 0
maxId, gkErr = gkDbCon.getMaxChatId()
if gkErr != nil {
return nil, gkErr
}
stmt, err = gkDbCon.sqlDb.Prepare("select chat_archives.message_creation_date, chat_archives.chat_message, users.user_name from users, chat_archives where users.id = chat_archives.user_id and chat_archives.id > $1 order by chat_archives.message_creation_date desc")
if err != nil {
return nil, gkerr.GenGkErr("sql.Prepare"+getDatabaseErrorMessage(err), err, ERROR_ID_PREPARE)
}
defer stmt.Close()
var rows *sql.Rows
if maxId > 0 {
startId = maxId - (int32(count) + 20)
}
rows, err = stmt.Query(startId)
if err != nil {
return nil, gkerr.GenGkErr("stmt.Query"+getDatabaseErrorMessage(err), err, ERROR_ID_QUERY)
}
defer rows.Close()
for rows.Next() {
var lugChatArchive LugChatArchiveDef
err = rows.Scan(&lugChatArchive.MessageCreationDate, &lugChatArchive.ChatMessage, &lugChatArchive.UserName)
if err != nil {
return nil, gkerr.GenGkErr("rows.Scan"+getDatabaseErrorMessage(err), err, ERROR_ID_ROWS_SCAN)
}
results = append(results, lugChatArchive)
if len(results) >= count {
break
}
}
return results, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:50,代码来源:chatArchives.go
示例13: NewGkRandContext
func NewGkRandContext() *GkRandContextDef {
var gkRandContext *GkRandContextDef = new(GkRandContextDef)
var seed int64
var err error
var gkErr *gkerr.GkErrDef
seed = time.Now().UnixNano()
buf := make([]byte, 6, 6)
_, err = c_rand.Read(buf)
if err != nil {
// log the error
// but this error is not fatal
gkErr = gkerr.GenGkErr("c_rand.Read", err, ERROR_ID_RAND_READ)
gklog.LogGkErr("", gkErr)
}
seed ^= int64(buf[0]) << 16
seed ^= int64(buf[1]) << 24
seed ^= int64(buf[2]) << 32
seed ^= int64(buf[3]) << 40
seed ^= int64(buf[4]) << 48
seed ^= int64(buf[5]) << 56
gkRandContext.mRandContext = m_rand.New(m_rand.NewSource(seed))
return gkRandContext
}
开发者ID:gk-turnip,项目名称:server,代码行数:27,代码来源:gkRand.go
示例14: queueMessageToClient
func (fieldContext *FieldContextDef) queueMessageToClient(sessionId string, messageToClient *message.MessageToClientDef) {
var websocketConnectionContext *websocketConnectionContextDef
var gkErr *gkerr.GkErrDef
gklog.LogTrace("queu up message " + messageToClient.Command)
websocketConnectionContext, gkErr =
fieldContext.getWebsocketConnectionContextById(sessionId)
if gkErr != nil {
gklog.LogGkErr("", gkErr)
} else {
var localSize int
websocketConnectionContext.toClientQueue.mutex.Lock()
localSize = websocketConnectionContext.toClientQueue.queueSize
websocketConnectionContext.toClientQueue.mutex.Unlock()
if localSize > MAX_MESSAGES_TO_CLIENT_QUEUE {
gkErr = gkerr.GenGkErr("messageToClient queue overflow, dropping message", nil, ERROR_ID_MESSAGE_TO_CLIENT_QUEUE_OVERFLOW)
gklog.LogGkErr("", gkErr)
} else {
websocketConnectionContext.toClientQueue.mutex.Lock()
websocketConnectionContext.toClientQueue.queueSize += 1
websocketConnectionContext.toClientQueue.mutex.Unlock()
websocketConnectionContext.toClientQueue.messagesChan <- messageToClient
}
}
}
开发者ID:gk-turnip,项目名称:server,代码行数:30,代码来源:queueMessage.go
示例15: BuildSvgMessageToClient
func (messageToClient *MessageToClientDef) BuildSvgMessageToClient(svgDir string, command string, fileName string, svgJsonData *SvgJsonDataDef) *gkerr.GkErrDef {
var gkErr *gkerr.GkErrDef
if !validateSvgFileName(fileName) {
gkErr = gkerr.GenGkErr("invalid svg fileName", nil, ERROR_ID_INVALID_SVG_FILENAME)
return gkErr
}
messageToClient.Command = command
jsonFileName := svgDir + string(os.PathSeparator) + fileName + ".json"
svgFileName := svgDir + string(os.PathSeparator) + fileName + ".svg"
messageToClient.JsonData, gkErr = gkcommon.GetFileContents(jsonFileName)
if gkErr != nil {
return gkErr
}
messageToClient.Data, gkErr = gkcommon.GetFileContents(svgFileName)
if gkErr != nil {
return gkErr
}
messageToClient.Data, gkErr = gksvg.FixSvgData(messageToClient.Data, fileName)
if gkErr != nil {
return gkErr
}
if svgJsonData != nil {
messageToClient.JsonData, gkErr = templateTranslateJsonData(messageToClient.JsonData, svgJsonData)
if gkErr != nil {
return gkErr
}
}
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:35,代码来源:toClient.go
示例16: GetBytes
func (gkTemplate *TemplateDef) GetBytes() ([]byte, *gkerr.GkErrDef) {
if gkTemplate.dataBuffer == nil {
return nil, gkerr.GenGkErr("missing call to Build", nil, ERROR_ID_MISSING_BUILD)
}
return gkTemplate.dataBuffer.Bytes(), nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:7,代码来源:gkTmpl.go
示例17: loadConfigFile
func loadConfigFile(fileName string) (loginConfigDef, *gkerr.GkErrDef) {
var err error
var loginConfig loginConfigDef
var file *os.File
file, err = os.Open(fileName)
if err != nil {
return loginConfig, gkerr.GenGkErr(fmt.Sprintf("os.Open file: %s", fileName), err, ERROR_ID_OPEN_CONFIG)
}
defer file.Close()
err = xml.NewDecoder(file).Decode(&loginConfig)
if err != nil {
return loginConfig, gkerr.GenGkErr(fmt.Sprintf("xml.NewDecoder file: %s", fileName), err, ERROR_ID_DECODE_CONFIG)
}
return loginConfig, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:18,代码来源:loginServerConfig.go
示例18: handleMessageFromClient
func (fieldContext *FieldContextDef) handleMessageFromClient(messageFromClient *message.MessageFromClientDef) *gkerr.GkErrDef {
var gkErr *gkerr.GkErrDef
switch messageFromClient.Command {
case message.GetAvatarSvgReq:
gkErr = fieldContext.handleGetAvatarSvgReq(messageFromClient)
if gkErr != nil {
return gkErr
}
case message.DelAvatarSvgReq:
gkErr = fieldContext.handleDelAvatarSvgReq(messageFromClient)
if gkErr != nil {
return gkErr
}
case message.MoveAvatarSvgReq:
gkErr = fieldContext.handleMoveAvatarSvgReq(messageFromClient)
if gkErr != nil {
return gkErr
}
case message.SetAvatarSvgReq:
gkErr = fieldContext.handleSetAvatarSvgReq(messageFromClient)
if gkErr != nil {
return gkErr
}
case message.PingReq:
gkErr = fieldContext.handlePingReq(messageFromClient)
if gkErr != nil {
return gkErr
}
case message.ChatReq:
gkErr = fieldContext.handleChatReq(messageFromClient)
if gkErr != nil {
return gkErr
}
case message.NewPodReq:
gkErr = fieldContext.handleNewPodReq(messageFromClient)
if gkErr != nil {
return gkErr
}
case message.UserPrefSaveReq:
gkErr = fieldContext.handleUserPrefReq(messageFromClient)
if gkErr != nil {
return gkErr
}
case message.SaveTerrainEditReq:
gkErr = fieldContext.handleSaveTerrainEditReq(messageFromClient)
if gkErr != nil {
return gkErr
}
default:
gkErr = gkerr.GenGkErr("unknonwn websocket request: "+messageFromClient.Command, nil, ERROR_ID_UNKNOWN_WEBSOCKET_COMMAND)
return gkErr
}
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:57,代码来源:handleMessageFromClient.go
示例19: UpdateUserPref
func (gkDbCon *GkDbConDef) UpdateUserPref(id int32, prefName string, prefValue string) *gkerr.GkErrDef {
var stmt *sql.Stmt
var err error
stmt, err = gkDbCon.sqlDb.Prepare("update user_prefs set pref_value = $1 where user_id = $2 and pref_name = $3")
if err != nil {
return gkerr.GenGkErr("stmt.Prepare "+getDatabaseErrorMessage(err), err, ERROR_ID_PREPARE)
}
defer stmt.Close()
_, err = stmt.Exec(prefValue, id, prefName)
if err != nil {
return gkerr.GenGkErr("stmt.Exec "+getDatabaseErrorMessage(err), err, ERROR_ID_EXECUTE)
}
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:19,代码来源:userPrefs.go
示例20: InsertUserPref
func (gkDbCon *GkDbConDef) InsertUserPref(id int32, prefName string, prefValue string) *gkerr.GkErrDef {
var stmt *sql.Stmt
var err error
stmt, err = gkDbCon.sqlDb.Prepare("insert into user_prefs (user_id, pref_value, pref_name) values ($1, $2, $3)")
if err != nil {
return gkerr.GenGkErr("stmt.Prepare "+getDatabaseErrorMessage(err), err, ERROR_ID_PREPARE)
}
defer stmt.Close()
_, err = stmt.Exec(id, prefValue, prefName)
if err != nil {
return gkerr.GenGkErr("stmt.Exec "+getDatabaseErrorMessage(err), err, ERROR_ID_EXECUTE)
}
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:19,代码来源:userPrefs.go
注:本文中的gk/gkerr.GenGkErr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论