forked from sijms/go-ora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_object.go
71 lines (67 loc) · 1.48 KB
/
simple_object.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package go_ora
import (
"errors"
"fmt"
"github.com/sijms/go-ora/network"
)
type simpleObject struct {
session *network.Session
operationID uint8
data []byte
err error
}
func (obj *simpleObject) write() *simpleObject {
//obj.session.ResetBuffer()
obj.session.PutBytes(3, obj.operationID, 0)
if obj.data != nil {
obj.session.PutBytes(obj.data...)
}
obj.err = obj.session.Write()
return obj
}
func (obj *simpleObject) read() error {
if obj.err != nil {
return obj.err
}
loop := true
for loop {
msg, err := obj.session.GetByte()
if err != nil {
return err
}
switch msg {
case 4:
obj.session.Summary, err = network.NewSummary(obj.session)
if err != nil {
return err
}
loop = false
case 9:
if obj.session.HasEOSCapability {
if obj.session.Summary == nil {
obj.session.Summary = new(network.SummaryObject)
}
obj.session.Summary.EndOfCallStatus, err = obj.session.GetInt(4, true, true)
if err != nil {
return err
}
}
if obj.session.HasFSAPCapability {
if obj.session.Summary == nil {
obj.session.Summary = new(network.SummaryObject)
}
obj.session.Summary.EndToEndECIDSequence, err = obj.session.GetInt(2, true, true)
if err != nil {
return err
}
}
loop = false
default:
return errors.New(fmt.Sprintf("message code error: received code %d and expected code is 4, 9", msg))
}
}
if obj.session.HasError() {
return errors.New(obj.session.GetError())
}
return nil
}